private IOrderedEnumerable<SentenceElement> dependantWords(Stage3ResultElement element) { var result = new List<SentenceElement>(); result.AddRange(element.ChainWordsIds.All.Values.Select(i => _sentence.ElementList.Find(word => word.Id == i))); result.Add(_sentence.ElementList.Find(x => x.Id == element.Id)); return result.OrderBy(word => word.Order); }
public override void ProcessSentence(Sentence sentence) { _sentence = sentence; Debug.Assert(sentence.ElementList != null); Debug.Assert(_meaningPartStage4Result != null); Debug.Assert(_mainPartsStage4Result != null); Debug.Assert(_selfStage1Result != null); Debug.Assert(sentence.ElementList.Count > 0); List<SentenceElement> words = sentence.ElementList; var excludeIds = new List<string>(); foreach (var item in _mainPartsStage4Result.Items) excludeIds.Add(item.Id); foreach (var item in _meaningPartStage4Result.Items) excludeIds.Add(item.Id); foreach (var stage1Result in _selfStage1Result.Items) { Stage3ResultElement item = new Stage3ResultElement(); item.CopyFromSourceWord(stage1Result); item.ObjectType = stage1Result.ObjectType; // первое слово ЗЦ не может быть союзом if (!item.IsConjuctive) { item.LoadChainList(excludeIds.ToArray(), ref words); Result.Items.Add(item); } else { item.LoadChainList(excludeIds.ToArray(), ref words); if (item.ChainWordsIds.Count > 0) { item.CopyFromSourceWord(words.Find(x => x.Id == item.ChainWordsIds.All.Values.First())); item.LoadChainList(excludeIds.ToArray(), ref words); Result.Items.Add(item); } } // родительский член не может быть восстановленным var parentChainElement = _sentence.ElementList.Find(x => x.Id == item.SyntacticParentWordId); if (parentChainElement !=null && parentChainElement.IsRestored && item.ChainWordsIds.Count > 0) { item.CopyFromSourceWord(_sentence.ElementList.Find(x => x.Id == item.ChainWordsIds.All.Values.First())); item.LoadChainList(excludeIds.ToArray(), ref words); } } }