static Pullenti.Ner.ReferentToken _tryAttachMoscowAO(List <TerrItemToken> li, Pullenti.Ner.Core.AnalyzerData ad) { if (li[0].TerminItem == null || !li[0].TerminItem.IsMoscowRegion) { return(null); } if (li[0].IsDoubt) { bool ok = false; if (CityAttachHelper.CheckCityAfter(li[0].EndToken.Next)) { ok = true; } else { List <Pullenti.Ner.Address.Internal.AddressItemToken> ali = Pullenti.Ner.Address.Internal.AddressItemToken.TryParseList(li[0].EndToken.Next, null, 2); if (ali != null && ali.Count > 0 && ali[0].Typ == Pullenti.Ner.Address.Internal.AddressItemToken.ItemType.Street) { ok = true; } } if (!ok) { return(null); } } Pullenti.Ner.Geo.GeoReferent reg = new Pullenti.Ner.Geo.GeoReferent(); string typ = "АДМИНИСТРАТИВНЫЙ ОКРУГ"; reg.AddTyp(typ); string name = li[0].TerminItem.CanonicText; if (Pullenti.Morph.LanguageHelper.EndsWith(name, typ)) { name = name.Substring(0, name.Length - typ.Length - 1).Trim(); } reg.AddName(name); return(new Pullenti.Ner.ReferentToken(reg, li[0].BeginToken, li[0].EndToken)); }
static bool _canBeGeoAfter(Pullenti.Ner.Token tt) { while (tt != null && ((tt.IsComma || Pullenti.Ner.Core.BracketHelper.IsBracket(tt, true)))) { tt = tt.Next; } if (tt == null) { return(false); } if (tt.GetReferent() is Pullenti.Ner.Geo.GeoReferent) { return(true); } List <TerrItemToken> tli = TerrItemToken.TryParseList(tt, null, 2); if (tli != null && tli.Count > 1) { if (tli[0].TerminItem == null && tli[1].TerminItem != null) { return(true); } else if (tli[0].TerminItem != null && tli[1].TerminItem == null) { return(true); } } if (CityAttachHelper.CheckCityAfter(tt)) { return(true); } if (TryAttachStateUSATerritory(tt) != null) { return(true); } return(false); }