Esempio n. 1
0
        private static PartSentence ConvertParseToSentence(Parse parse)
        {
            int start         = parse.Span.Start;
            int end           = parse.Span.End;
            var parseSentence = new PartSentence {
                StartIndex = start,
                EndIndex   = end,
                Type       = _typeConverter.ConvertToPhraseType(parse.Type),
                Text       = GetPartText(parse, start, end)
            };

            return(parseSentence);
        }
Esempio n. 2
0
        private Sentence ConvertToSentence(Parse parse)
        {
            if (parse.Type == MaximumEntropyParser.TopNode)
            {
                parse = parse.GetChildren()[0];
            }

            PartSentence parseSentence = ConvertParseToSentence(parse);
            var          result        = new Sentence(parseSentence);

            if (!parse.IsPosTag)
            {
                AddChildNodes(result, parseSentence, parse.GetChildren());
            }
            else
            {
                //внутри есть только слова
                Word word = ConvertToWord(result, parse);
                parseSentence.AddWord(word);
            }
            return(result);
        }
Esempio n. 3
0
        private void AddChildNodes(Sentence sentence, PartSentence partSentence, IEnumerable <Parse> childParses)
        {
            foreach (Parse childParse in childParses)
            {
                if (childParse.Type == MaximumEntropyParser.TokenNode)
                {
                    continue;
                }

                if (childParse.IsPosTag)
                {
                    //внутри есть только слова
                    Word word = ConvertToWord(sentence, childParse);
                    partSentence.AddWord(word);
                    continue;
                }

                //есть вложенные части предложений - обработать их
                PartSentence childPartSentence = ConvertParseToSentence(childParse);
                childPartSentence.Parent = partSentence;
                partSentence.AddChildren(childPartSentence);
                AddChildNodes(sentence, childPartSentence, childParse.GetChildren());
            }
        }
Esempio n. 4
0
 internal void AddChildren(PartSentence part)
 {
     _parts.Add(part);
 }
Esempio n. 5
0
 public Sentence(PartSentence partSentence)
 {
     _partSentence = partSentence;
 }