public NomFlex GetAllPossibleFlexes(string word, List <Flex> flexes, string result_word, string cur_nom_reestr) { NomFlex result = new NomFlex(); foreach (Flex flex in flexes) { if ((word + flex.flex) == result_word) { result.nom = GetNomByReestr(cur_nom_reestr); result.flex = flex; break; } } return(result); }
public WordInfo GetNomEntity(string word, List <Nom> checkedNoms, string fullWord) { WordInfo result = new WordInfo(); IQueryable <Nom> noms = context.Nom1.Where(x => x.reestr.StartsWith(word.ToLower())); if (checkedNoms.Count() > 0) { noms = noms.Except(checkedNoms); } Nom potentialResult = noms.FirstOrDefault(x => x.reestr == fullWord); if (potentialResult != null) { result.nom = potentialResult; result.indent = context.Indents.FirstOrDefault(x => x.type == potentialResult.@type); return(result); } if (noms == null || noms.Count() == 0) { return(GetNomEntity(word.Remove(word.Length - 1), checkedNoms, fullWord)); } else { foreach (Nom nom in noms) { Indent indentOfNewWord = context.Indents.FirstOrDefault(x => x.type == nom.@type); string newWord = String.Empty; if (indentOfNewWord.indent > 0) { newWord = nom.reestr.Remove(nom.reestr.Length - indentOfNewWord.indent); } else { newWord = nom.reestr; } if (!word.StartsWith(newWord)) { continue; } if (newWord == fullWord) { result.nom = nom; result.indent = indentOfNewWord; break; } IQueryable <Flex> flexes = context.Flexes.Where(x => x.type == nom.type && x.flex.Length == (fullWord.Length - newWord.Length)); NomFlex res = new NomFlex(); if (flexes.Count() > 0) { res = GetAllPossibleFlexes(newWord, flexes.ToList(), fullWord, nom.reestr); } if (res != null && res.nom != null && res.nom.reestr != null) { result.nom = res.nom; result.indent = indentOfNewWord; result.flex = res.flex; continue; } } } if (result.nom == null && word.Length > 1) { return(GetNomEntity(word.Remove(word.Length - 1), noms.Concat(checkedNoms).ToList(), fullWord)); } return(result); }