コード例 #1
0
        /// <summary>
        /// Преобразовать наречие в прилагательное (это пока только для русского языка)
        /// </summary>
        /// <param name="adverb">наречие</param>
        /// <param name="bi">род число падеж</param>
        /// <return>прилагательное</return>
        public static string ConvertAdverbToAdjective(string adverb, MorphBaseInfo bi)
        {
            if (adverb == null || (adverb.Length < 4))
            {
                return(null);
            }
            char last = adverb[adverb.Length - 1];

            if (last != 'О' && last != 'Е')
            {
                return(adverb);
            }
            string        var1 = adverb.Substring(0, adverb.Length - 1) + "ИЙ";
            string        var2 = adverb.Substring(0, adverb.Length - 1) + "ЫЙ";
            MorphWordForm bi1  = GetWordBaseInfo(var1, null, false, false);
            MorphWordForm bi2  = GetWordBaseInfo(var2, null, false, false);
            string        var  = var1;

            if (!bi1.Class.IsAdjective && bi2.Class.IsAdjective)
            {
                var = var2;
            }
            if (bi == null)
            {
                return(var);
            }
            return(m_Morph.GetWordform(var, MorphClass.Adjective, bi.Gender, bi.Case, bi.Number, MorphLang.Unknown, null) ?? var);
        }
コード例 #2
0
        /// <summary>
        /// Получить вариант написания словоформы
        /// </summary>
        /// <param name="word">слово</param>
        /// <param name="morphInfo">морфологическая информация</param>
        /// <return>вариант написания</return>
        public static string GetWordform(string word, MorphBaseInfo morphInfo)
        {
            if (morphInfo == null || string.IsNullOrEmpty(word))
            {
                return(word);
            }
            MorphClass cla = morphInfo.Class;

            if (cla.IsUndefined)
            {
                MorphWordForm mi0 = GetWordBaseInfo(word, null, false, false);
                if (mi0 != null)
                {
                    cla = mi0.Class;
                }
            }
            string word1 = word;

            foreach (char ch in word)
            {
                if (char.IsLower(ch))
                {
                    word1 = word.ToUpper();
                    break;
                }
            }
            MorphWordForm wf  = morphInfo as MorphWordForm;
            string        res = m_Morph.GetWordform(word1, cla, morphInfo.Gender, morphInfo.Case, morphInfo.Number, morphInfo.Language, wf);

            if (string.IsNullOrEmpty(res))
            {
                return(word);
            }
            return(res);
        }
コード例 #3
0
        public virtual bool CheckAccord(MorphBaseInfo v, bool ignoreGender = false, bool ignoreNumber = false)
        {
            if (v.Language != Language)
            {
                if (v.Language == MorphLang.Unknown && Language == MorphLang.Unknown)
                {
                    return(false);
                }
            }
            MorphNumber num = v.Number & Number;

            if (num == MorphNumber.Undefined && !ignoreNumber)
            {
                if (v.Number != MorphNumber.Undefined && Number != MorphNumber.Undefined)
                {
                    if (v.Number == MorphNumber.Singular && v.Case.IsGenitive)
                    {
                        if (Number == MorphNumber.Plural && Case.IsGenitive)
                        {
                            if (((v.Gender & MorphGender.Masculine)) == MorphGender.Masculine)
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                }
            }
            if (!ignoreGender && num != MorphNumber.Plural)
            {
                if (((v.Gender & Gender)) == MorphGender.Undefined)
                {
                    if (v.Gender != MorphGender.Undefined && Gender != MorphGender.Undefined)
                    {
                        return(false);
                    }
                }
            }
            if (((v.Case & Case)).IsUndefined)
            {
                if (!v.Case.IsUndefined && !Case.IsUndefined)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #4
0
        public void CopyFrom(MorphBaseInfo src)
        {
            MorphClass cla = new MorphClass();

            cla.Value = src.Class.Value;
            Class     = cla;
            Gender    = src.Gender;
            Number    = src.Number;
            MorphCase cas = new MorphCase();

            cas.Value = src.Case.Value;
            Case      = cas;
            MorphLang lng = new MorphLang();

            lng.Value = src.Language.Value;
            Language  = lng;
        }