/// <summary> /// Initialize DictMatch Feature Generator /// </summary> /// <returns></returns> public bool Initialize() { dictmatch = new DictMatch(); dm_r = new List<Lemma>(); dm_offsetList = new List<int>(); Dictionary<string, string> configDict; configDict = LoadConfigFile("GenerateFeatureDictMatch.ini"); if (configDict.ContainsKey(KEY_LEXICAL_DICT_FILE_NAME.ToLower()) == false || configDict.ContainsKey(KEY_BINARY_DICT_TYPE.ToLower()) == false) { return false; } var strDictMatchFileName = configDict[KEY_LEXICAL_DICT_FILE_NAME.ToLower()]; var bBinaryDict = bool.Parse(configDict[KEY_BINARY_DICT_TYPE.ToLower()]); if (strDictMatchFileName.Length == 0) { return true; } if (bBinaryDict == true) { dictmatch.LoadDictFromBinary(strDictMatchFileName); } else { dictmatch.LoadDictFromRawText(strDictMatchFileName); } return true; }
public static void VerifyBinaryDict(string strTestFileName, string strRawDictFileName) { Console.WriteLine("Convert dictionary from raw text to binary format."); DictMatch match = new DictMatch(); match.ConvertDictFromRawTextToBinary(strRawDictFileName, strRawDictFileName + ".bin"); Console.WriteLine("Load binary dictionary..."); match = new DictMatch(); match.LoadDictFromBinary(strRawDictFileName + ".bin"); Console.WriteLine("Verify binary dictionary..."); Match(strTestFileName, match); }