Exemple #1
0
        /// создание морфоформы из строки
        private MorphoForm CreateMorphoForm(MorphoType morphoType, string line, List <MorphoAttributePair> morphoAttributePairs)
        {
            int index = line.IndexOf(':');

            if (index < 0)
            {
                throw (new MorphoFormatException());
            }

            var ending = StringsHelper.ToLowerInvariant(line.Substring(0, index).Trim());

            if (ending == EMPTY_ENDING)
            {
                ending = string.Empty;
            }

            morphoAttributePairs.Clear();
            var attributes = line.Substring(index + 1).Split(MORPHO_ATTRIBUTE_SEPARATOR, StringSplitOptions.RemoveEmptyEntries);

            foreach (var attribute in attributes)
            {
                var attr = attribute.Trim();
                if (!string.IsNullOrEmpty(attr))
                {
                    var morphoAttribute = default(MorphoAttributeEnum);
                    if (Enum.TryParse(attr, true, out morphoAttribute))
                    {
                        //---morphoAttributePairs.Add( _MorphoAttributeList.GetMorphoAttributePair( morphoType.MorphoAttributeGroup, morphoAttribute ) );

                        var map = _MorphoAttributeList.TryGetMorphoAttributePair(morphoType.MorphoAttributeGroup, morphoAttribute);
                        if (map.HasValue)
                        {
                            morphoAttributePairs.Add(map.Value);
                        }
#if DEBUG
                        //TOO MANY ERRORS AFTER last (2016.12.28) getting morpho-dcitionaries from 'lingvo-[ilook]'
                        else
                        {
                            _ModelLoadingErrorCallback("Error in morpho-attribute: '" + attr + '\'', line);
                        }
#endif
                    }
                    else
                    {
                        _ModelLoadingErrorCallback("Unknown morpho-attribute: '" + attr + '\'', line);
                    }
                }
            }
            var morphoForm = new MorphoForm(ending, morphoAttributePairs);
            return(morphoForm);
        }