public override bool CanBeGeneralFor(Pullenti.Ner.Referent obj) { if (!this._CanBeEquals(obj, Pullenti.Ner.Core.ReferentsEqualType.WithinOneText, true)) { return(false); } Pullenti.Ner.Geo.GeoReferent g1 = this.GetSlotValue(ATTR_GEO) as Pullenti.Ner.Geo.GeoReferent; Pullenti.Ner.Geo.GeoReferent g2 = obj.GetSlotValue(ATTR_GEO) as Pullenti.Ner.Geo.GeoReferent; if (g1 == null && g2 != null) { return(true); } return(false); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { InstrumentParticipantReferent p = obj as InstrumentParticipantReferent; if (p == null) { return(false); } if (Typ != p.Typ) { return(false); } Pullenti.Ner.Referent re1 = this.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; Pullenti.Ner.Referent re2 = obj.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; if (re1 != null && re2 != null) { if (!re1.CanBeEquals(re2, typ)) { return(false); } } return(true); }
void _recalcTmpBits() { m_TmpBits = 1; m_Higher = null; GeoReferent hi = this.GetSlotValue(ATTR_HIGHER) as GeoReferent; if (hi == this || hi == null) { } else { List <Pullenti.Ner.Referent> li = null; bool err = false; for (Pullenti.Ner.Referent r = hi.GetSlotValue(ATTR_HIGHER) as Pullenti.Ner.Referent; r != null; r = r.GetSlotValue(ATTR_HIGHER) as Pullenti.Ner.Referent) { if (r == hi || r == this) { err = true; break; } if (li == null) { li = new List <Pullenti.Ner.Referent>(); } else if (li.Contains(r)) { err = true; break; } li.Add(r); } if (!err) { m_Higher = hi; } } int isState = -1; int isReg = -1; foreach (Pullenti.Ner.Slot t in Slots) { if (t.TypeName == ATTR_TYPE) { string val = t.Value as string; if (val == "территория" || val == "територія" || val == "territory") { m_TmpBits = 1 | BIT_ISTERRITORY; return; } if (_isCity(val)) { m_TmpBits |= BIT_ISCITY; if ((val == "город" || val == "місто" || val == "city") || val == "town") { m_TmpBits |= BIT_ISBIGCITY; } continue; } if ((val == "государство" || val == "держава" || val == "империя") || val == "імперія" || val == "country") { m_TmpBits |= BIT_ISSTATE; isReg = 0; continue; } if (_isRegion(val)) { if (isState < 0) { isState = 0; } if (isReg < 0) { isReg = 1; } } } else if (t.TypeName == ATTR_ALPHA2) { m_TmpBits = 1 | BIT_ISSTATE; if (this.FindSlot(ATTR_TYPE, "город", true) != null || this.FindSlot(ATTR_TYPE, "місто", true) != null || this.FindSlot(ATTR_TYPE, "city", true) != null) { m_TmpBits |= (BIT_ISBIGCITY | BIT_ISCITY); } return; } } if (isState != 0) { if ((isState < 0) && ((m_TmpBits & BIT_ISCITY)) != 0) { } else { m_TmpBits |= BIT_ISSTATE; } } if (isReg != 0) { if ((isState < 0) && ((m_TmpBits & BIT_ISCITY)) != 0) { } else { m_TmpBits |= BIT_ISREGION; } } }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { NamedEntityReferent ent = obj as NamedEntityReferent; if (ent == null) { return(false); } if (ent.Kind != Kind) { return(false); } List <string> names = this.GetStringValues(ATTR_NAME); List <string> names2 = obj.GetStringValues(ATTR_NAME); bool eqNames = false; if ((names != null && names.Count > 0 && names2 != null) && names2.Count > 0) { foreach (string n in names) { if (names2.Contains(n)) { eqNames = true; } } if (!eqNames) { return(false); } } List <string> typs = this.GetStringValues(ATTR_TYPE); List <string> typs2 = obj.GetStringValues(ATTR_TYPE); bool eqTyps = false; if ((typs != null && typs.Count > 0 && typs2 != null) && typs2.Count > 0) { foreach (string ty in typs) { if (typs2.Contains(ty)) { eqTyps = true; } } if (!eqTyps) { return(false); } } if (!eqTyps && !eqNames) { return(false); } Pullenti.Ner.Referent re1 = this.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; Pullenti.Ner.Referent re2 = obj.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; if (re1 != null && re2 != null) { if (!re1.CanBeEquals(re2, typ)) { return(false); } } else if (re1 != null || re2 != null) { } return(true); }
static Pullenti.Ner.Token CorrectTailAttributes(Pullenti.Ner.Person.PersonReferent p, Pullenti.Ner.Token t0) { Pullenti.Ner.Token res = t0; Pullenti.Ner.Token t = t0; if (t != null && t.IsChar(',')) { t = t.Next; } bool born = false; bool die = false; if (t != null && ((t.IsValue("РОДИТЬСЯ", "НАРОДИТИСЯ") || t.IsValue("BORN", null)))) { t = t.Next; born = true; } else if (t != null && ((t.IsValue("УМЕРЕТЬ", "ПОМЕРТИ") || t.IsValue("СКОНЧАТЬСЯ", null) || t.IsValue("DIED", null)))) { t = t.Next; die = true; } else if ((t != null && t.IsValue("ДАТА", null) && t.Next != null) && t.Next.IsValue("РОЖДЕНИЕ", "НАРОДЖЕННЯ")) { t = t.Next.Next; born = true; } while (t != null) { if (t.Morph.Class.IsPreposition || t.IsHiphen || t.IsChar(':')) { t = t.Next; } else { break; } } if (t != null && t.GetReferent() != null) { Pullenti.Ner.Referent r = t.GetReferent(); if (r.TypeName == "DATE") { Pullenti.Ner.Token t1 = t; if (t.Next != null && ((t.Next.IsValue("Р", null) || t.Next.IsValue("РОЖДЕНИЕ", "НАРОДЖЕННЯ")))) { born = true; t1 = t.Next; if (t1.Next != null && t1.Next.IsChar('.')) { t1 = t1.Next; } } if (born) { if (p != null) { p.AddSlot(Pullenti.Ner.Person.PersonReferent.ATTR_BORN, r, false, 0); } res = t1; t = t1; } else if (die) { if (p != null) { p.AddSlot(Pullenti.Ner.Person.PersonReferent.ATTR_DIE, r, false, 0); } res = t1; t = t1; } } } if (die && t != null) { Pullenti.Ner.NumberToken ag = Pullenti.Ner.Core.NumberHelper.TryParseAge(t.Next); if (ag != null) { if (p != null) { p.AddSlot(Pullenti.Ner.Person.PersonReferent.ATTR_AGE, ag.Value.ToString(), false, 0); } t = ag.EndToken.Next; res = ag.EndToken; } } if (t == null) { return(res); } if (t.IsChar('(')) { Pullenti.Ner.Core.BracketSequenceToken br = Pullenti.Ner.Core.BracketHelper.TryParse(t, Pullenti.Ner.Core.BracketParseAttr.No, 100); if (br != null) { Pullenti.Ner.Token t1 = t.Next; born = false; if (t1.IsValue("РОД", null)) { born = true; t1 = t1.Next; if (t1 != null && t1.IsChar('.')) { t1 = t1.Next; } } if (t1 is Pullenti.Ner.ReferentToken) { Pullenti.Ner.Referent r = t1.GetReferent(); if (r.TypeName == "DATERANGE" && t1.Next == br.EndToken) { Pullenti.Ner.Referent bd = r.GetSlotValue("FROM") as Pullenti.Ner.Referent; Pullenti.Ner.Referent to = r.GetSlotValue("TO") as Pullenti.Ner.Referent; if (bd != null && to != null) { if (p != null) { p.AddSlot(Pullenti.Ner.Person.PersonReferent.ATTR_BORN, bd, false, 0); p.AddSlot(Pullenti.Ner.Person.PersonReferent.ATTR_DIE, to, false, 0); } t = (res = br.EndToken); } } else if (r.TypeName == "DATE" && t1.Next == br.EndToken) { if (p != null) { p.AddSlot(Pullenti.Ner.Person.PersonReferent.ATTR_BORN, r, false, 0); } t = (res = br.EndToken); } } } } return(res); }