public static bool CheckCityAfter(Pullenti.Ner.Token tt) { while (tt != null && (((tt.IsCommaAnd || tt.IsHiphen || tt.Morph.Class.IsPreposition) || tt.IsChar('.')))) { tt = tt.Next; } if (tt == null) { return(false); } List <CityItemToken> cits = CityItemToken.TryParseList(tt, null, 5); if (cits == null || cits.Count == 0) { if (tt.LengthChar == 1 && tt.Chars.IsAllLower && ((tt.IsValue("Д", null) || tt.IsValue("П", null)))) { Pullenti.Ner.Token tt1 = tt.Next; if (tt1 != null && tt1.IsChar('.')) { tt1 = tt1.Next; } CityItemToken ci = CityItemToken.TryParse(tt1, null, false, null); if (ci != null && ((ci.Typ == CityItemToken.ItemType.ProperName || ci.Typ == CityItemToken.ItemType.City))) { return(true); } } return(false); } if (TryAttachCity(cits, null, false) != null) { return(true); } if (cits[0].Typ == CityItemToken.ItemType.Noun) { if (tt.Previous != null && tt.Previous.IsComma) { return(true); } } return(false); }
public static bool CheckGeoObjectAfter(Pullenti.Ner.Token t, bool dontCheckCity = false) { if (t == null) { return(false); } int cou = 0; for (Pullenti.Ner.Token tt = t.Next; tt != null; tt = tt.Next) { if (tt.IsCharOf(",.;") || tt.IsHiphen || tt.Morph.Class.IsConjunction) { continue; } if (tt.Morph.Class.IsPreposition) { if (!dontCheckCity && tt.IsValue("С", null) && tt.Next != null) { Pullenti.Ner.Token ttt = tt.Next; if (ttt.IsChar('.') && (ttt.Next.WhitespacesAfterCount < 3)) { ttt = ttt.Next; } List <CityItemToken> cits = CityItemToken.TryParseList(ttt, null, 3); if (cits != null && cits.Count == 1 && ((cits[0].Typ == CityItemToken.ItemType.ProperName || cits[0].Typ == CityItemToken.ItemType.City))) { if (tt.Chars.IsAllUpper && !cits[0].Chars.IsAllUpper) { } else { return(true); } } } continue; } if (tt.IsValue("ТЕРРИТОРИЯ", "ТЕРИТОРІЯ")) { continue; } Pullenti.Ner.ReferentToken rt = tt as Pullenti.Ner.ReferentToken; if (rt == null) { if (!dontCheckCity) { List <CityItemToken> cits = CityItemToken.TryParseList(tt, null, 3); if ((cits != null && cits.Count == 2 && cits[0].Typ == CityItemToken.ItemType.Noun) && ((cits[1].Typ == CityItemToken.ItemType.ProperName || cits[1].Typ == CityItemToken.ItemType.City))) { if (cits[0].Chars.IsAllUpper && !cits[1].Chars.IsAllUpper) { } else { return(true); } } } if ((tt is Pullenti.Ner.TextToken) && tt.LengthChar > 2 && cou == 0) { cou++; continue; } else { break; } } if ((rt.Referent is Pullenti.Ner.Geo.GeoReferent) || (rt.Referent is Pullenti.Ner.Address.AddressReferent) || (rt.Referent is Pullenti.Ner.Address.StreetReferent)) { return(true); } break; } return(false); }