/// <summary> /// 设置文字拼音词库 /// </summary> /// <param name="pathConfig">文字拼音词库</param> public void Set(DictPinYinPathConfig pathConfig) { pathConfig = Get(); pathConfig.PinYinNamePath = string.IsNullOrEmpty(pathConfig.PinYinNamePath) ? "Dict/PinYin/pinyinName.txt" : pathConfig.PinYinNamePath; pathConfig.PinYinIndexPath = string.IsNullOrEmpty(pathConfig.PinYinIndexPath) ? "Dict/PinYin/pinyinIndex.txt" : pathConfig.PinYinIndexPath; pathConfig.PinYinDataPath = string.IsNullOrEmpty(pathConfig.PinYinDataPath) ? "Dict/PinYin/pinyinData.txt" : pathConfig.PinYinDataPath; pathConfig.WordPath = string.IsNullOrEmpty(pathConfig.WordPath) ? "Dict/PinYin/pinyinWord.txt" : pathConfig.WordPath; pathConfig.WordPinYinPath = string.IsNullOrEmpty(pathConfig.WordPinYinPath) ? "Dict/PinYin/wordPinyin.txt" : pathConfig.WordPinYinPath; }
/// <summary> /// /// </summary> public BaseWordService(EWordConfig wordConfig) { if (wordConfig == null) { wordConfig = new EWordConfig(); } Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); DictTextPathConfig = DictTextPathConfig.Get(); DictPinYinPathConfig = DictPinYinPathConfig.Get(); DictTextPathConfig.Set(wordConfig.DictTextPathConfig); DictPinYinPathConfig.Set(wordConfig.DictPinYinPathConfig); if (DictConfig == null) { Reload(DictTypeEnum.Text); } if (DictPinYinConfig == null) { Reload(DictTypeEnum.PinYin); } }
/// <summary> /// 读取文字拼音词库 /// </summary> /// <returns></returns> internal static DictPinYinPathConfig Get() { return(Config ?? (Config = new DictPinYinPathConfig())); }