public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { BookLinkRefReferent r = obj as BookLinkRefReferent; if (r == null) { return(false); } if (Book != r.Book) { return(false); } if (Number != r.Number) { return(false); } if (Pages != r.Pages) { return(false); } if ((Typ == BookLinkRefType.Inline) != (r.Typ == BookLinkRefType.Inline)) { return(false); } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { MoneyReferent s = obj as MoneyReferent; if (s == null) { return(false); } if (s.Currency != Currency) { return(false); } if (s.Value != Value) { return(false); } if (s.Rest != Rest) { return(false); } if (s.AltValue != AltValue) { return(false); } if (s.AltRest != AltRest) { return(false); } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { PersonIdentityReferent id = obj as PersonIdentityReferent; if (id == null) { return(false); } if (Typ != id.Typ) { return(false); } if (Number != id.Number) { return(false); } if (State != null && id.State != null) { if (State != id.State) { return(false); } } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { DateRangeReferent dr = obj as DateRangeReferent; if (dr == null) { return(false); } if (DateFrom != null) { if (!DateFrom.CanBeEquals(dr.DateFrom, typ)) { return(false); } } else if (dr.DateFrom != null) { return(false); } if (DateTo != null) { if (!DateTo.CanBeEquals(dr.DateTo, typ)) { return(false); } } else if (dr.DateTo != null) { return(false); } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { UriReferent uri = obj as UriReferent; if (uri == null) { return(false); } return(string.Compare(Value, uri.Value, true) == 0); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { DateReferent sd = obj as DateReferent; if (sd == null) { return(false); } if (sd.IsRelative != IsRelative) { return(false); } if (sd.Century != Century) { return(false); } if (sd.Year != Year) { return(false); } if (sd.Month != Month) { return(false); } if (sd.Day != Day) { return(false); } if (sd.Hour != Hour) { return(false); } if (sd.Minute != Minute) { return(false); } if (sd.Second != Second) { return(false); } if (sd.Pointer != Pointer) { return(false); } if (sd.DayOfWeek > 0 && DayOfWeek > 0) { if (sd.DayOfWeek != DayOfWeek) { return(false); } } return(true); }
bool _canBeEqual(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ, bool ignoreAddNumber) { PhoneReferent ph = obj as PhoneReferent; if (ph == null) { return(false); } if (ph.CountryCode != null && CountryCode != null) { if (ph.CountryCode != CountryCode) { return(false); } } if (ignoreAddNumber) { if (AddNumber != null && ph.AddNumber != null) { if (ph.AddNumber != AddNumber) { return(false); } } } else if (AddNumber != null || ph.AddNumber != null) { if (AddNumber != ph.AddNumber) { return(false); } } if (Number == null || ph.Number == null) { return(false); } if (Number == ph.Number) { return(true); } if (typ != Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { if (Pullenti.Morph.LanguageHelper.EndsWith(Number, ph.Number) || Pullenti.Morph.LanguageHelper.EndsWith(ph.Number, Number)) { return(true); } } return(false); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { KeywordReferent kw = obj as KeywordReferent; if (kw == null) { return(false); } KeywordType ki = Typ; if (ki != kw.Typ) { return(false); } if (ki == KeywordType.Referent) { Pullenti.Ner.Referent re = this.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; if (re == null) { return(false); } Pullenti.Ner.Referent re2 = kw.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; if (re2 == null) { return(false); } if (re.CanBeEquals(re2, typ)) { return(true); } } foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_NORMAL || s.TypeName == ATTR_VALUE) { if (kw.FindSlot(ATTR_NORMAL, s.Value, true) != null) { return(true); } if (kw.FindSlot(ATTR_VALUE, s.Value, true) != null) { return(true); } } } return(false); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { DenominationReferent dr = obj as DenominationReferent; if (dr == null) { return(false); } foreach (string n in NameVars) { if (dr.NameVars.Contains(n)) { return(true); } } return(false); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { InstrumentArtefactReferent p = obj as InstrumentArtefactReferent; if (p == null) { return(false); } if (Typ != p.Typ) { return(false); } if (Value != p.Value) { return(false); } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { DefinitionReferent dr = obj as DefinitionReferent; if (dr == null) { return(false); } if (Termin != dr.Termin) { return(false); } if (Value != dr.Value) { return(false); } if (TerminAdd != dr.TerminAdd) { return(false); } return(true); }
/// <summary> /// Проверка возможной тождественности сущностей /// </summary> /// <param name="obj">другая сущность</param> /// <param name="typ">тип сравнения</param> /// <return>результат</return> public virtual bool CanBeEquals(Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { if (obj == null || obj.TypeName != TypeName) { return(false); } foreach (Slot r in Slots) { if (r.Value != null && obj.FindSlot(r.TypeName, r.Value, false) == null) { return(false); } } foreach (Slot r in obj.Slots) { if (r.Value != null && this.FindSlot(r.TypeName, r.Value, true) == null) { return(false); } } return(true); }
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); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { BankDataReferent bd = obj as BankDataReferent; if (bd == null) { return(false); } foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_ITEM) { Pullenti.Ner.Uri.UriReferent ur = s.Value as Pullenti.Ner.Uri.UriReferent; string val = bd.FindValue(ur.Scheme); if (val != null) { if (val != ur.Value) { return(false); } } } else if (s.TypeName == ATTR_BANK) { Pullenti.Ner.Referent b1 = s.Value as Pullenti.Ner.Referent; Pullenti.Ner.Referent b2 = bd.GetSlotValue(ATTR_BANK) as Pullenti.Ner.Referent; if (b2 != null) { if (b1 != b2 && !b1.CanBeEquals(b2, Pullenti.Ner.Core.ReferentsEqualType.WithinOneText)) { return(false); } } } } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { UnitReferent ur = obj as UnitReferent; if (ur == null) { return(false); } foreach (Pullenti.Ner.Slot s in Slots) { if (ur.FindSlot(s.TypeName, s.Value, true) == null) { return(false); } } foreach (Pullenti.Ner.Slot s in ur.Slots) { if (this.FindSlot(s.TypeName, s.Value, true) == null) { return(false); } } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { BookLinkReferent br = obj as BookLinkReferent; if (br == null) { return(false); } int eq = 0; if (Year > 0 && br.Year > 0) { if (Year == br.Year) { eq++; } else { return(false); } } if (Typ != null && br.Typ != null) { if (Typ != br.Typ) { return(false); } } bool eqAuth = false; if (this.FindSlot(ATTR_AUTHOR, null, true) != null && br.FindSlot(ATTR_AUTHOR, null, true) != null) { bool ok = false; foreach (Pullenti.Ner.Slot a in Slots) { if (a.TypeName == ATTR_AUTHOR) { if (br.FindSlot(ATTR_AUTHOR, a.Value, true) != null) { eq++; ok = true; eqAuth = true; } } } if (!ok) { return(false); } } if (br.Name != Name) { if (Name == null || br.Name == null) { return(false); } if (Name.StartsWith(br.Name) || br.Name.StartsWith(Name)) { eq += 1; } else if (eqAuth && Pullenti.Ner.Core.MiscHelper.CanBeEquals(Name, br.Name, false, true, false)) { eq += 1; } else { return(false); } } else { eq += 2; } return(eq > 2); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { return(obj == this); }
bool _canBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ, bool ignoreGeo) { StreetReferent stri = obj as StreetReferent; if (stri == null) { return(false); } if (Kind != stri.Kind) { return(false); } List <string> typs1 = Typs; List <string> typs2 = stri.Typs; bool ok = false; if (typs1.Count > 0 && typs2.Count > 0) { foreach (string t in typs1) { if (typs2.Contains(t)) { ok = true; break; } } if (!ok) { return(false); } } string num = Number; string num1 = stri.Number; if (num != null || num1 != null) { if (num == null || num1 == null) { return(false); } string sec = SecNumber; string sec1 = stri.SecNumber; if (sec == null && sec1 == null) { if (num != num1) { return(false); } } else if (num == num1) { if (sec != sec1) { return(false); } } else if (sec == num1 && sec1 == num) { } else { return(false); } } List <string> names1 = Names; List <string> names2 = stri.Names; if (names1.Count > 0 || names2.Count > 0) { ok = false; foreach (string n in names1) { if (names2.Contains(n)) { ok = true; break; } } if (!ok) { return(false); } } if (ignoreGeo) { return(true); } List <Pullenti.Ner.Geo.GeoReferent> geos1 = Geos; List <Pullenti.Ner.Geo.GeoReferent> geos2 = stri.Geos; if (geos1.Count > 0 && geos2.Count > 0) { ok = false; foreach (Pullenti.Ner.Geo.GeoReferent g1 in geos1) { foreach (Pullenti.Ner.Geo.GeoReferent g2 in geos2) { if (g1.CanBeEquals(g2, typ)) { ok = true; break; } } } if (!ok) { if (City != null && stri.City != null) { ok = City.CanBeEquals(stri.City, typ); } } if (!ok) { return(false); } } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { PersonPropertyReferent pr = obj as PersonPropertyReferent; if (pr == null) { return(false); } string n1 = Name; string n2 = pr.Name; if (n1 == null || n2 == null) { return(false); } bool eqBosses = false; if (n1 != n2) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } if (m_Bosses0.Contains(n1) && m_Bosses1.Contains(n2)) { eqBosses = true; } else if (m_Bosses1.Contains(n1) && m_Bosses0.Contains(n2)) { eqBosses = true; } else { if (!n1.StartsWith(n2 + " ") && !n2.StartsWith(n1 + " ")) { return(false); } eqBosses = true; } for (PersonPropertyReferent hi = Higher; hi != null; hi = hi.Higher) { if ((++_tmpStack) > 20) { } else if (hi.CanBeEquals(pr, typ)) { _tmpStack--; return(false); } _tmpStack--; } for (PersonPropertyReferent hi = pr.Higher; hi != null; hi = hi.Higher) { if ((++_tmpStack) > 20) { } else if (hi.CanBeEquals(this, typ)) { _tmpStack--; return(false); } _tmpStack--; } } if (Higher != null && pr.Higher != null) { if ((++_tmpStack) > 20) { } else if (!Higher.CanBeEquals(pr.Higher, typ)) { _tmpStack--; return(false); } _tmpStack--; } if (this.FindSlot("@GENERAL", null, true) != null || pr.FindSlot("@GENERAL", null, true) != null) { return(this.ToString() == pr.ToString()); } if (this.FindSlot(ATTR_REF, null, true) != null || pr.FindSlot(ATTR_REF, null, true) != null) { List <object> refs1 = new List <object>(); List <object> refs2 = new List <object>(); foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_REF) { refs1.Add(s.Value); } } foreach (Pullenti.Ner.Slot s in pr.Slots) { if (s.TypeName == ATTR_REF) { refs2.Add(s.Value); } } bool eq = false; bool noeq = false; for (int i = 0; i < refs1.Count; i++) { if (refs2.Contains(refs1[i])) { eq = true; continue; } noeq = true; if (refs1[i] is Pullenti.Ner.Referent) { foreach (object rr in refs2) { if (rr is Pullenti.Ner.Referent) { if ((rr as Pullenti.Ner.Referent).CanBeEquals(refs1[i] as Pullenti.Ner.Referent, typ)) { noeq = false; eq = true; break; } } } } } for (int i = 0; i < refs2.Count; i++) { if (refs1.Contains(refs2[i])) { eq = true; continue; } noeq = true; if (refs2[i] is Pullenti.Ner.Referent) { foreach (object rr in refs1) { if (rr is Pullenti.Ner.Referent) { if ((rr as Pullenti.Ner.Referent).CanBeEquals(refs2[i] as Pullenti.Ner.Referent, typ)) { noeq = false; eq = true; break; } } } } } if (eq && !noeq) { } else if (noeq && ((eq || refs1.Count == 0 || refs2.Count == 0))) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts || n1 != n2) { return(false); } if (Higher != null || pr.Higher != null) { return(false); } } else { return(false); } } else if (!eqBosses && n1 != n2) { return(false); } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { TransportReferent tr = obj as TransportReferent; if (tr == null) { return(false); } TransportKind k1 = Kind; TransportKind k2 = tr.Kind; if (k1 != k2) { if (k1 == TransportKind.Space && tr.FindSlot(ATTR_TYPE, "КОРАБЛЬ", true) != null) { } else if (k2 == TransportKind.Space && this.FindSlot(ATTR_TYPE, "КОРАБЛЬ", true) != null) { k1 = TransportKind.Space; } else { return(false); } } Pullenti.Ner.Slot sl = this.FindSlot(ATTR_ORG, null, true); if (sl != null && tr.FindSlot(ATTR_ORG, null, true) != null) { if (tr.FindSlot(ATTR_ORG, sl.Value, false) == null) { return(false); } } sl = this.FindSlot(ATTR_GEO, null, true); if (sl != null && tr.FindSlot(ATTR_GEO, null, true) != null) { if (tr.FindSlot(ATTR_GEO, sl.Value, true) == null) { return(false); } } string s1 = this.GetStringValue(ATTR_NUMBER); string s2 = tr.GetStringValue(ATTR_NUMBER); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else { if (s1 != s2) { return(false); } s1 = this.GetStringValue(ATTR_NUMBER_REGION); s2 = tr.GetStringValue(ATTR_NUMBER_REGION); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else if (s1 != s2) { return(false); } } } } s1 = this.GetStringValue(ATTR_BRAND); s2 = tr.GetStringValue(ATTR_BRAND); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else if (s1 != s2) { return(false); } } s1 = this.GetStringValue(ATTR_MODEL); s2 = tr.GetStringValue(ATTR_MODEL); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else if (s1 != s2) { return(false); } } foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_NAME) { if (tr.FindSlot(ATTR_NAME, s.Value, true) != null) { return(true); } } } if (s1 != null && s2 != null) { return(true); } return(false); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { return(this._canBeEquals(obj, typ, false)); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { bool b = this._CanBeEquals(obj, typ, false); return(b); }
bool _CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ, bool ignoreGeo) { DecreeReferent dr = obj as DecreeReferent; if (dr == null) { return(false); } if (dr.Typ0 != null && Typ0 != null) { if (dr.Typ0 != Typ0) { return(false); } } int numEq = 0; if (Number != null || dr.Number != null) { if (Number != null && dr.Number != null) { List <string> di1 = this._allNumberDigits(); List <string> di2 = dr._allNumberDigits(); foreach (string d1 in di1) { if (di2.Contains(d1)) { numEq = 1; break; } } if (numEq == 0 && !IsLaw) { return(false); } foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_NUMBER) { if (dr.FindSlot(s.TypeName, s.Value, true) != null) { numEq = 2; break; } } } if (numEq == 0) { return(false); } } } if (CaseNumber != null && dr.CaseNumber != null) { if (CaseNumber != dr.CaseNumber) { return(false); } } if (this.FindSlot(ATTR_GEO, null, true) != null && dr.FindSlot(ATTR_GEO, null, true) != null) { if (this.GetStringValue(ATTR_GEO) != dr.GetStringValue(ATTR_GEO)) { return(false); } } bool srcEq = false; bool srcNotEq = false; Pullenti.Ner.Slot src = this.FindSlot(ATTR_SOURCE, null, true); if (src != null && dr.FindSlot(ATTR_SOURCE, null, true) != null) { if (dr.FindSlot(src.TypeName, src.Value, true) == null) { srcNotEq = true; } else { srcEq = true; } } bool dateNotEq = false; bool dateIsEqu = false; bool yearsIsEqu = false; string date1 = this.GetStringValue(ATTR_DATE); string date2 = dr.GetStringValue(ATTR_DATE); if (date1 != null || date2 != null) { if (IsLaw) { List <int> ys1 = this._allYears(); List <int> ys2 = dr._allYears(); foreach (int y1 in ys1) { if (ys2.Contains(y1)) { yearsIsEqu = true; break; } } if (yearsIsEqu) { List <DateTime> dts1 = this._allDates(); List <DateTime> dts2 = dr._allDates(); foreach (DateTime d1 in dts1) { if (dts2.Contains(d1)) { dateIsEqu = true; break; } } } if (!dateIsEqu) { if (Typ == "КОНСТИТУЦИЯ") { return(false); } if (Date != null && dr.Date != null) { dateNotEq = true; } } } else if (date1 == date2 || ((Date != null && dr.Date != null && Date == dr.Date))) { if (numEq > 1) { return(true); } dateIsEqu = true; } else if (Date != null && dr.Date != null) { if (Date.Value.Year != dr.Date.Value.Year) { return(false); } if (numEq >= 1) { if (srcEq) { return(true); } if (srcNotEq) { return(false); } } else { return(false); } } else if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts || Kind == DecreeKind.Publisher) { dateNotEq = true; } } if (this.FindSlot(ATTR_NAME, null, true) != null && dr.FindSlot(ATTR_NAME, null, true) != null) { foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_NAME) { if (dr.FindSlot(s.TypeName, s.Value, true) != null) { return(true); } foreach (Pullenti.Ner.Slot ss in dr.Slots) { if (ss.TypeName == s.TypeName) { string n0 = s.Value.ToString(); string n1 = ss.Value.ToString(); if (n0.StartsWith(n1) || n1.StartsWith(n0)) { return(true); } } } } } if (dateNotEq) { return(false); } if (IsLaw && !dateIsEqu) { return(false); } if (numEq > 0) { if (srcEq) { return(true); } if (srcNotEq && typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } else if ((!srcNotEq && numEq > 1 && Date == null) && dr.Date == null) { return(true); } return(false); } } else if (IsLaw && dateNotEq) { return(false); } if (dateNotEq) { return(false); } string ty = Typ; if (ty == null) { return(numEq > 0); } DecreeKind t = Pullenti.Ner.Decree.Internal.DecreeToken.GetKind(ty); if (t == DecreeKind.Ustav || ty == "КОНСТИТУЦИЯ") { return(true); } if (numEq > 0) { return(true); } if (this.ToString() == obj.ToString()) { return(true); } return(false); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { AddressReferent addr = obj as AddressReferent; if (addr == null) { return(false); } List <Pullenti.Ner.Referent> strs1 = Streets; List <Pullenti.Ner.Referent> strs2 = addr.Streets; if (strs1.Count > 0 || strs2.Count > 0) { bool ok = false; foreach (Pullenti.Ner.Referent s in strs1) { foreach (Pullenti.Ner.Referent ss in strs2) { if (ss.CanBeEquals(s, typ)) { ok = true; break; } } } if (!ok) { return(false); } } if (addr.House != null || House != null) { if (addr.House != House) { return(false); } } if (addr.Building != null || Building != null) { if (addr.Building != Building) { return(false); } } if (addr.Plot != null || Plot != null) { if (addr.Plot != Plot) { return(false); } } if (addr.Box != null || Box != null) { if (addr.Box != Box) { return(false); } } if (addr.Block != null || Block != null) { if (addr.Block != Block) { return(false); } } if (addr.Corpus != null || Corpus != null) { if (addr.Corpus != Corpus) { if (addr.Corpus != null && addr.Corpus == CorpusOrFlat) { } else if (Corpus != null && addr.CorpusOrFlat == Corpus) { } else { return(false); } } } if (addr.Flat != null || Flat != null) { if (addr.Flat != Flat) { if (addr.Flat != null && addr.Flat == CorpusOrFlat) { } else if (Flat != null && addr.CorpusOrFlat == Flat) { } else { return(false); } } } if (addr.CorpusOrFlat != null || CorpusOrFlat != null) { if (CorpusOrFlat != null && addr.CorpusOrFlat != null) { if (CorpusOrFlat != addr.CorpusOrFlat) { return(false); } } else if (CorpusOrFlat == null) { if (Corpus == null && Flat == null) { return(false); } } else if (addr.CorpusOrFlat == null) { if (addr.Corpus == null && addr.Flat == null) { return(false); } } } if (addr.Office != null || Office != null) { if (addr.Office != Office) { return(false); } } if (addr.Potch != null || Potch != null) { if (addr.Potch != Potch) { return(false); } } if (addr.Floor != null || Floor != null) { if (addr.Floor != Floor) { return(false); } } if (addr.PostOfficeBox != null || PostOfficeBox != null) { if (addr.PostOfficeBox != PostOfficeBox) { return(false); } } if (addr.CSP != null && CSP != null) { if (addr.CSP != CSP) { return(false); } } List <Pullenti.Ner.Geo.GeoReferent> geos1 = Geos; List <Pullenti.Ner.Geo.GeoReferent> geos2 = addr.Geos; if (geos1.Count > 0 && geos2.Count > 0) { bool ok = false; foreach (Pullenti.Ner.Geo.GeoReferent g1 in geos1) { foreach (Pullenti.Ner.Geo.GeoReferent g2 in geos2) { if (g1.CanBeEquals(g2, typ)) { ok = true; break; } } } if (!ok) { return(false); } } return(true); }
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); }
bool _CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ, bool ignoreGeo) { DecreePartReferent dr = obj as DecreePartReferent; if (dr == null) { return(false); } if (Owner != null && dr.Owner != null) { if (Owner != dr.Owner) { return(false); } } else if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } else { string ty1 = (Owner == null ? LocalTyp : Owner.Typ); string ty2 = (dr.Owner == null ? dr.LocalTyp : dr.Owner.Typ); if (ty1 != ty2) { ty1 = (Owner == null ? LocalTyp : Owner.Typ0); ty2 = (dr.Owner == null ? dr.LocalTyp : dr.Owner.Typ0); if (ty1 != ty2) { return(false); } } } if (Clause != dr.Clause) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Clause == null || dr.Clause == null))) { } else { return(false); } } if (Part != dr.Part) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Part == null || dr.Part == null))) { } else { return(false); } } if (Paragraph != dr.Paragraph) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Paragraph == null || dr.Paragraph == null))) { } else { return(false); } } if (SubParagraph != dr.SubParagraph) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((SubParagraph == null || dr.SubParagraph == null))) { } else { return(false); } } if (Item != dr.Item) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Item == null || dr.Item == null))) { } else { return(false); } } if (SubItem != dr.SubItem) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((SubItem == null || dr.SubItem == null))) { } else { return(false); } } if (Notice != dr.Notice) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Notice == null || dr.Notice == null))) { } else { return(false); } } if (Indention != dr.Indention) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Indention == null || dr.Indention == null))) { } else { return(false); } } if (SubIndention != dr.SubIndention) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((SubIndention == null || dr.SubIndention == null))) { } else { return(false); } } if (Appendix != dr.Appendix) { if (Appendix != null && dr.Appendix != null) { return(false); } if (Clause == null && Paragraph == null && Item == null) { return(false); } } if (Chapter != dr.Chapter) { if (Chapter != null && dr.Chapter != null) { return(false); } if (Clause == null && Paragraph == null && Item == null) { return(false); } } if (Section != dr.Section) { if (Section != null && dr.Section != null) { return(false); } if ((Clause == null && Paragraph == null && Item == null) && SubSection == null) { return(false); } } if (SubSection != dr.SubSection) { if (SubSection != null && dr.SubSection != null) { return(false); } if (Clause == null && Paragraph == null && Item == null) { return(false); } } if (Subprogram != null || dr.Subprogram != null) { if (Name != dr.Name) { return(false); } return(true); } if (Addagree != null || dr.Addagree != null) { if (Addagree != dr.Addagree) { return(false); } } if (DocPart != dr.DocPart) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((DocPart == null || dr.DocPart == null))) { } else { return(false); } } if (Page != dr.Page) { return(false); } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { GoodAttributeReferent a = obj as GoodAttributeReferent; if (a == null) { return(false); } if (a.Typ != Typ) { return(false); } string u1 = this.GetStringValue(ATTR_UNIT); string u2 = a.GetStringValue(ATTR_UNIT); if (u1 != null && u2 != null) { if (u1 != u2) { if (u1.Length == (u2.Length + 1) && u1 == (u2 + ".")) { } else if (u2.Length == (u1.Length + 1) && u2 == (u1 + ".")) { } return(false); } } string nam1 = this.GetStringValue(ATTR_NAME); string nam2 = a.GetStringValue(ATTR_NAME); if (nam1 != null || nam2 != null) { if (nam1 != nam2) { return(false); } } bool eq = false; if (Ref != null || a.Ref != null) { if (Ref == null || a.Ref == null) { return(false); } if (!Ref.CanBeEquals(a.Ref, typ)) { return(false); } eq = true; } if (Typ != GoodAttrType.Numeric) { foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_VALUE || s.TypeName == ATTR_ALTVALUE) { if (a.FindSlot(ATTR_VALUE, s.Value, true) != null || a.FindSlot(ATTR_ALTVALUE, s.Value, true) != null) { eq = true; break; } } } } else { List <string> vals1 = Values; List <string> vals2 = a.Values; if (vals1.Count != vals2.Count) { return(false); } foreach (string v in vals1) { if (!vals2.Contains(v)) { return(false); } } } if (!eq) { return(false); } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { GeoReferent geo = obj as GeoReferent; if (geo == null) { return(false); } if (geo.Alpha2 != null && geo.Alpha2 == Alpha2) { return(true); } if (IsCity != geo.IsCity) { return(false); } if (IsUnion != geo.IsUnion) { return(false); } if (IsUnion) { foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_REF) { if (obj.FindSlot(ATTR_REF, s.Value, true) == null) { return(false); } } } foreach (Pullenti.Ner.Slot s in obj.Slots) { if (s.TypeName == ATTR_REF) { if (this.FindSlot(ATTR_REF, s.Value, true) == null) { return(false); } } } return(true); } Pullenti.Ner.Referent ref1 = this.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; Pullenti.Ner.Referent ref2 = geo.GetSlotValue(ATTR_REF) as Pullenti.Ner.Referent; if (ref1 != null && ref2 != null) { if (ref1 != ref2) { return(false); } } bool r = IsRegion || IsState; bool r1 = geo.IsRegion || geo.IsState; if (r != r1) { if (IsTerritory != geo.IsTerritory) { return(false); } return(false); } bool eqNames = false; foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_NAME) { if (geo.FindSlot(s.TypeName, s.Value, true) != null) { eqNames = true; break; } } } if (!eqNames) { return(false); } if (IsRegion && geo.IsRegion) { List <string> typs1 = Typs; List <string> typs2 = geo.Typs; bool ok = false; foreach (string t in typs1) { if (typs2.Contains(t)) { ok = true; } else { foreach (string tt in typs2) { if (Pullenti.Morph.LanguageHelper.EndsWith(tt, t) || Pullenti.Morph.LanguageHelper.EndsWith(t, tt)) { ok = true; } } } } if (!ok) { return(false); } } if (Higher != null && geo.Higher != null) { if (_checkRoundDep(this) || _checkRoundDep(geo)) { return(false); } if (Higher.CanBeEquals(geo.Higher, typ)) { } else if (geo.Higher.Higher != null && Higher.CanBeEquals(geo.Higher.Higher, typ)) { } else if (Higher.Higher != null && Higher.Higher.CanBeEquals(geo.Higher, typ)) { } else { return(false); } } return(true); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ) { PersonReferent p = obj as PersonReferent; if (p == null) { return(false); } foreach (Pullenti.Ner.Slot a in Slots) { if (a.TypeName == ATTR_IDENTITY) { foreach (Pullenti.Ner.Slot aa in p.Slots) { if (aa.TypeName == a.TypeName) { if (_DelSurnameEnd(a.Value as string) == _DelSurnameEnd(aa.Value as string)) { return(true); } } } } } string nick1 = this.GetStringValue(ATTR_NICKNAME); string nick2 = obj.GetStringValue(ATTR_NICKNAME); if (nick1 != null && nick2 != null) { if (nick1 != nick2) { return(false); } } if (this.FindSlot(ATTR_LASTNAME, null, true) != null && p.FindSlot(ATTR_LASTNAME, null, true) != null) { if (!this.CompareSurnamesPers(p)) { return(false); } if (this.FindSlot(ATTR_FIRSTNAME, null, true) != null && p.FindSlot(ATTR_FIRSTNAME, null, true) != null) { if (!this.CheckNames(ATTR_FIRSTNAME, p)) { return(false); } if (this.FindSlot(ATTR_MIDDLENAME, null, true) != null && p.FindSlot(ATTR_MIDDLENAME, null, true) != null) { if (!this.CheckNames(ATTR_MIDDLENAME, p)) { return(false); } } else if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { if (this.FindSlot(ATTR_MIDDLENAME, null, true) != null || p.FindSlot(ATTR_MIDDLENAME, null, true) != null) { return(this.ToString() == p.ToString()); } List <string> names1 = new List <string>(); List <string> names2 = new List <string>(); foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_FIRSTNAME) { string nam = s.Value.ToString(); if (!IsInitial(nam)) { names1.Add(nam); } } } foreach (Pullenti.Ner.Slot s in p.Slots) { if (s.TypeName == ATTR_FIRSTNAME) { string nam = s.Value.ToString(); if (!IsInitial(nam)) { if (names1.Contains(nam)) { return(true); } names2.Add(nam); } } } if (names1.Count == 0 && names2.Count == 0) { return(true); } return(false); } } else if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts && ((this.FindSlot(ATTR_FIRSTNAME, null, true) != null || p.FindSlot(ATTR_FIRSTNAME, null, true) != null))) { return(false); } return(true); } string tit1 = this._findShortestKingTitul(false); string tit2 = p._findShortestKingTitul(false); if (((tit1 != null || tit2 != null)) || ((nick1 != null && nick1 == nick2))) { if (tit1 == null || tit2 == null) { if (nick1 != null && nick1 == nick2) { } else { return(false); } } else if (tit1 != tit2) { if (!tit1.Contains(tit2) && !tit2.Contains(tit1)) { return(false); } } if (this.FindSlot(ATTR_FIRSTNAME, null, true) != null && p.FindSlot(ATTR_FIRSTNAME, null, true) != null) { if (!this.CheckNames(ATTR_FIRSTNAME, p)) { return(false); } return(true); } } return(false); }
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { WeaponReferent tr = obj as WeaponReferent; if (tr == null) { return(false); } string s1 = this.GetStringValue(ATTR_NUMBER); string s2 = tr.GetStringValue(ATTR_NUMBER); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else { if (s1 != s2) { return(false); } return(true); } } bool eqTypes = false; foreach (string t in this.GetStringValues(ATTR_TYPE)) { if (tr.FindSlot(ATTR_TYPE, t, true) != null) { eqTypes = true; break; } } if (!eqTypes) { return(false); } s1 = this.GetStringValue(ATTR_BRAND); s2 = tr.GetStringValue(ATTR_BRAND); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else if (s1 != s2) { return(false); } } s1 = this.GetStringValue(ATTR_MODEL); s2 = tr.GetStringValue(ATTR_MODEL); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else { if (this.FindSlot(ATTR_MODEL, s2, true) != null) { return(true); } if (tr.FindSlot(ATTR_MODEL, s1, true) != null) { return(true); } return(false); } } foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_NAME) { if (tr.FindSlot(ATTR_NAME, s.Value, true) != null) { return(true); } } } if (s1 != null && s2 != null) { return(true); } return(false); }