示例#1
0
        /// чтение файла со словами
        /// path - полный путь к файлу
        /// nounType - тип существительного
        private void ReadWords(string filename, MorphoAttributeEnum nounType)
        {
            var lines = ReadFile(filename);

            foreach (var line in lines)
            {
                #region commented
                //try
                //{
                #endregion
                var array = line.Split(WORDS_DICTIONARY_SEPARATOR, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length != 3)
                {
                    _ModelLoadingErrorCallback("Wrong line format", line);   //throw (new MorphoFormatException());
                    continue;
                }

                MorphoType morphoType = GetMorphoTypeByName(array[1]);
                if (morphoType == null)
                {
                    _ModelLoadingErrorCallback("Unknown morpho-type", line);   //throw new UnknownMorphoTypeException();
                }
                else
                if (array[2] != _PartOfSpeechStringDictionary[morphoType.PartOfSpeech])
                {
                    _ModelLoadingErrorCallback("Wrong part-of-speech", line);   //throw new WrongPartOfSpeechException();
                }
                else
                {
                    var word = array[0];

                    /*
                     * if ( word == "коем" )
                     *  System.Diagnostics.Debugger.Break();
                     * //*/

                    var _nounType = default(MorphoAttributePair?);
                    if ((morphoType.MorphoAttributeGroup & MorphoAttributeGroupEnum.NounType) == MorphoAttributeGroupEnum.NounType)
                    {
                        _nounType = _MorphoAttributeList.GetMorphoAttributePair(MorphoAttributeGroupEnum.NounType, nounType);
                    }
                    _TreeDictionary.AddWord(word, morphoType, _nounType);
                }
                #region commented
                //}
                //catch (UnknownMorphoTypeException)
                //{
                //    CMorphoModel::Logging("Unknown MorphoType", str);
                //    m_isInitialized = false;
                //}
                //catch (WrongPartOfSpeechException)
                //{
                //    CMorphoModel::Logging("Wrong PartOfSpeech", str);
                //    m_isInitialized = false;
                //}
                #endregion
            }
        }
示例#2
0
        /// чтение файла со словами
        /// path - полный путь к файлу
        /// nounType - тип существительного
        private void ReadWords(string filename, MorphoAttributeEnum nounType)
        {
            var lines = ReadFile(filename);

            foreach (var line in lines)
            {
                var array = line.Split(WORDS_DICTIONARY_SEPARATOR, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length != 3)
                {
                    _ModelLoadingErrorCallback("Wrong line format", line);
                    continue;
                }

                MorphoType morphoType = GetMorphoTypeByName(array[1]);
                if (morphoType == null)
                {
                    _ModelLoadingErrorCallback("Unknown morpho-type", line);
                }
                else
                if (array[2] != _PartOfSpeechStringDictionary[morphoType.PartOfSpeech])
                {
                    _ModelLoadingErrorCallback("Wrong part-of-speech", line);
                }
                else
                {
                    var word = array[0];

                    var _nounType = default(MorphoAttributePair?);
                    if ((morphoType.MorphoAttributeGroup & MorphoAttributeGroupEnum.NounType) == MorphoAttributeGroupEnum.NounType)
                    {
                        _nounType = _MorphoAttributeList.GetMorphoAttributePair(MorphoAttributeGroupEnum.NounType, nounType);
                    }
                    _TreeDictionary.AddWord(word, morphoType, _nounType);
                }
            }
        }