static void _processBlock(Pullenti.Semantic.SemDocument res, Pullenti.Ner.AnalysisResult ar, Pullenti.Ner.Token t0, Pullenti.Ner.Token t1) { Pullenti.Semantic.SemBlock blk = new Pullenti.Semantic.SemBlock(res); for (Pullenti.Ner.Token t = t0; t != null && t.EndChar <= t1.EndChar; t = t.Next) { Pullenti.Ner.Token te = t; for (Pullenti.Ner.Token tt = t.Next; tt != null && tt.EndChar <= t1.EndChar; tt = tt.Next) { if (Pullenti.Ner.Core.MiscHelper.CanBeStartOfSentence(tt)) { break; } else { te = tt; } } _processSentence(blk, ar, t, te); t = te; } if (blk.Fragments.Count > 0) { res.Blocks.Add(blk); } }
static void _processSentence(Pullenti.Semantic.SemBlock blk, Pullenti.Ner.AnalysisResult ar, Pullenti.Ner.Token t0, Pullenti.Ner.Token t1) { int cou = 0; for (Pullenti.Ner.Token t = t0; t != null && (t.EndChar < t1.EndChar); t = t.Next, cou++) { } if (cou > 70) { int cou2 = 0; for (Pullenti.Ner.Token t = t0; t != null && (t.EndChar < t1.EndChar); t = t.Next, cou2++) { if (cou2 >= 70) { t1 = t; break; } } } List <Sentence> sents = Sentence.ParseVariants(t0, t1, 0, 100, SentItemType.Undefined); if (sents == null) { return; } double max = (double)-1; Sentence best = null; Sentence alt = null; foreach (Sentence s in sents) { if ((t1 is Pullenti.Ner.TextToken) && !t1.Chars.IsLetter) { s.LastChar = t1 as Pullenti.Ner.TextToken; } s.CalcCoef(false); if (s.Coef > max) { max = s.Coef; best = s; alt = null; } else if (s.Coef == max && max > 0) { alt = s; } } if (best != null && best.ResBlock != null) { best.AddToBlock(blk, null); } }