Ejemplo n.º 1
0
        public override void ProcessSentence(Sentence sentence)
        {
            _sentence = sentence;
            Debug.Assert(_stage3Result != null);

            // ищем частицы и вспомогательные глаголы
            List<SentenceWord> particles = sentence.WordList.Where(x => x.PartOfSpeech.Value == PartOfSpeech.Particle.Value).ToList();
            List<SentenceWord> auxVerbs = sentence.WordList.Where(x => x.IsAuxVerb).ToList();

            foreach (var itemStage3 in _stage3Result.Items)
            {
                Stage4ResultElement item = new Stage4ResultElement();
                item.CopyFromSourceWord(itemStage3);
                List<int> itemStag3Ids = itemStage3.AddedWordsCase1.Concat(itemStage3.AddedWordsCase2).Concat(itemStage3.ServiceParts).Select(x => x.Id).ToList();
                SentenceWord particle;
                SentenceWord auxVerb;

                particle = particles.Find(x => x.DOM == item.Id);
                if (particle != null)
                {
                    SentenceWord word = new SentenceWord();
                    word.CopyFromSourceWord(particle);
                    if (!itemStag3Ids.Contains(word.Id))
                        item.ServiceParts.Add(word);
                }

                particle = particles.Find(x => item.ServiceParts.Concat(item.AddedWordsCase1).Concat(item.AddedWordsCase2).Select(y => y.Id).ToList().Contains(x.DOM));
                if (particle != null)
                {
                    SentenceWord word = new SentenceWord();
                    word.CopyFromSourceWord(particle);
                    if (!itemStag3Ids.Contains(word.Id))
                        item.ServiceParts.Add(word);
                }

                auxVerb = auxVerbs.Find(x => x.DOM == item.Id);
                if (auxVerb != null)
                {
                    SentenceWord word = new SentenceWord();
                    word.CopyFromSourceWord(auxVerb);
                    if (!itemStag3Ids.Contains(word.Id))
                        item.ServiceParts.Add(word);
                }

                auxVerb = auxVerbs.Find(x => item.AddedWordsCase1.Concat(item.AddedWordsCase2).Select(y => y.Id).ToList().Contains(x.DOM));
                if (auxVerb != null)
                {
                    SentenceWord word = new SentenceWord();
                    word.CopyFromSourceWord(auxVerb);
                    if (!itemStag3Ids.Contains(word.Id))
                        item.ServiceParts.Add(word);
                }

                Result.Items.Add(item);
            }

            Result.Items.RemoveAll(x => x.IsConjuction);
            foreach (var item in Result.Items)
            {
                item.ServiceParts.RemoveAll(x => x.IsConjuction);
            }

            // определяем принадлежность к ПП
            foreach (var item in Result.Items)
            {
                foreach (var ssItem in _simpleSentenceStage3Result.Items)
                {
                    var ssWordIds = ssItem.Id.Concat(ssItem.ChainWordsIds.All.Values);
                    if (ssWordIds.Contains(item.Id))
                    {
                        item.SimpleSentenceNr = ssItem.SimpleSentenceNr;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private IOrderedEnumerable<SentenceWord> _compileMainPart(Stage4ResultElement mainPart)
        {
            var result = new List<SentenceWord> { mainPart };

            result.AddRange(mainPart.ServiceParts);
            result.AddRange(mainPart.AddedWordsCase1);
            result.AddRange(mainPart.AddedWordsCase2);

            return result.OrderBy(word => word.Order);
        }