/// <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); }
public override bool ContainsAttr(string attrValue, MorphClass cla = null) { if (Misc != null && Misc.Attrs != null) { return(Misc.Attrs.Contains(attrValue)); } return(false); }
/// <summary> /// Получить для словоформы род\число\падеж /// </summary> /// <param name="word">словоформа</param> /// <param name="lang">возможный язык</param> /// <param name="isCaseNominative">исходное слово в именительном падеже (иначе считается падеж любым)</param> /// <param name="inDictOnly">при true не строить гипотезы для несловарных слов</param> /// <return>базовая морфологическая информация</return> public static MorphWordForm GetWordBaseInfo(string word, MorphLang lang = null, bool isCaseNominative = false, bool inDictOnly = false) { List <MorphToken> mt = m_Morph.Run(word, false, lang, false, null); MorphWordForm bi = new MorphWordForm(); MorphClass cla = new MorphClass(); if (mt != null && mt.Count > 0) { for (int k = 0; k < 2; k++) { bool ok = false; foreach (MorphWordForm wf in mt[0].WordForms) { if (k == 0) { if (!wf.IsInDictionary) { continue; } } else if (wf.IsInDictionary) { continue; } if (isCaseNominative) { if (!wf.Case.IsNominative && !wf.Case.IsUndefined) { continue; } } cla.Value |= wf.Class.Value; bi.Gender |= wf.Gender; bi.Case |= wf.Case; bi.Number |= wf.Number; if (wf.Misc != null && bi.Misc == null) { bi.Misc = wf.Misc; } ok = true; } if (ok || inDictOnly) { break; } } } bi.Class = cla; return(bi); }
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; }
public virtual bool ContainsAttr(string attrValue, MorphClass cla = null) { return(false); }