public void LoadDict(string dictpath) { Dict dict = new Dict(); dictFile = dict.LoadFromBinFile(dictpath + "Dict.dct"); foreach (WordPos word in dictFile.WordPosList) { _POS.AddWordPos(word.Word, word.Pos); } }
/// <summary> /// 初始化分词组件的工作环境。文件读取异常应在调用时进行处理。 /// </summary> /// <param name="segwords">主词典的Xml文件</param> /// <param name="segchsstopwords">中文停止词词典的Xml文件</param> /// <param name="segchssymbol">中文标点符号的Xml文件</param> /// <param name="segengstopwords">英文停止词词典的Xml文件</param> /// <param name="segengsymbol">英文标点符号的Xml文件</param> public static void Initialize( string segwords, string segchsstopwords, string segchssymbol, string segengstopwords, string segengsymbol) { SegWords = LoadSegWords(segwords); SegChsStopwordDic = LoadStopwords(segchsstopwords, SegChsStopwordDic); SegChsStopwordDic = LoadStopwords(segchssymbol, SegChsStopwordDic); SegEngStopwordDic = LoadStopwords(segengstopwords, SegEngStopwordDic); SegEngStopwordDic = LoadStopwords(segengsymbol, SegEngStopwordDic); ExtractInfo = new ExtractInfo(); _WordPosBuilder = new WordPosBuilder(); ExtractInfo.CompareByPosEvent = CompareByPos; foreach (WordPos item in SegWords.WordPosList) { ExtractInfo.InsertWordToDfa(item.Word); _WordPosBuilder.AddWordPos(item.Word, item.Pos); } SetOwnerRules(); }