/// <summary> /// Выводит все поддерживаемые теги /// </summary> /// <returns> /// Перечисление тегов /// </returns> public IEnumerable <Tag> ListSupportedTags() { return(TagsDic.OrderByDescending(kp => TagOrderDic[kp.Key]) .Select(kp => new Tag(kp.Value, 1, kp.Key))); }
/// <summary> /// Возвращает теги, которые подходят для данной комбинации граммем /// </summary> /// <param name="post">Часть речи</param> /// <param name="gndr">Род</param> /// <param name="nmbr">Число</param> /// <param name="case">Падеж</param> /// <param name="pers">Лицо</param> /// <param name="tens">Время</param> /// <param name="mood">Наклонение</param> /// <param name="voic">Залог</param> /// <param name="fullMatch"> /// Полное соответствие (игнорировать ли незаполненные грамматические категории)</param> /// <returns> /// Перечисление тегов с перечисленными граммемами /// </returns> public IEnumerable <Tag> FilterTags(string post, string gndr = null, string nmbr = null, string @case = null, string pers = null, string tens = null, string mood = null, string voic = null, bool fullMatch = false) { return(TagsDic.Where(t => { if (t.Value[_postKey] != post) { return false; } var tGndr = t.Value.ContainsKey(_gndrKey) ? t.Value[_gndrKey] : null; var fm = fullMatch ? true : gndr != null; if (fm && tGndr != gndr) { return false; } var tNmbr = t.Value.ContainsKey(_nmbrKey) ? t.Value[_nmbrKey] : null; fm = fullMatch ? true : nmbr != null; if (fm && tNmbr != nmbr) { return false; } var tCase = t.Value.ContainsKey(_caseKey) ? t.Value[_caseKey] : null; fm = fullMatch ? true : @case != null; if (fm && tCase != @case) { return false; } var tPers = t.Value.ContainsKey(_persKey) ? t.Value[_persKey] : null; fm = fullMatch ? true : pers != null; if (fm && tPers != pers) { return false; } var tTens = t.Value.ContainsKey(_tensKey) ? t.Value[_tensKey] : null; fm = fullMatch ? true : tens != null; if (fm && tTens != tens) { return false; } var tMood = t.Value.ContainsKey(_moodKey) ? t.Value[_moodKey] : null; fm = fullMatch ? true : mood != null; if (fm && tMood != mood) { return false; } var tVoid = t.Value.ContainsKey(_voicKey) ? t.Value[_voicKey] : null; fm = fullMatch ? true : tens != null; if (fm && tVoid != voic) { return false; } return true; }) .Select(kp => new Tag(kp.Value, 1, kp.Key)) .OrderByDescending(t => t.Id)); }