AdvUtils.DictMatch.LoadDictFromRawText C# (CSharp) Метод

LoadDictFromRawText() публичный Метод

public LoadDictFromRawText ( string fullpath ) : void
fullpath string
Результат void
        public void LoadDictFromRawText(string fullpath)
        {
            Init();

            StreamReader sr = new StreamReader(fullpath);
            while (sr.EndOfStream == false)
            {
                string strLine = sr.ReadLine();
                string[] items = strLine.Split(new char[] { '\t' });

                string strTerm;
                string strProp = "";

                if (items.Length < 1)
                {
                    throw new System.Exception("dict file is invalidated");
                }
                strTerm = items[0]; //.Trim();
                //Ignore empty line
                if (strTerm.Length == 0)
                {
                    continue;
                }

                if (items.Length == 2)
                {
                    strProp = items[1];
                }

                if (AddLemma(strTerm, strProp) < 0)
                {
                    throw new System.Exception("dm_dict_load error!");
                }
            }
            sr.Close();
        }

Usage Example

Пример #1
0
        /// <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;
        }
All Usage Examples Of AdvUtils.DictMatch::LoadDictFromRawText