コード例 #1
0
        public override void MergeSlots(Pullenti.Ner.Referent obj, bool mergeStatistic = true)
        {
            base.MergeSlots(obj, mergeStatistic);
            PersonReferent p = obj as PersonReferent;

            m_SurnameOccurs.AddRange(p.m_SurnameOccurs);
            m_NameOccurs.AddRange(p.m_NameOccurs);
            m_SecOccurs.AddRange(p.m_SecOccurs);
            m_IdentOccurs.AddRange(p.m_IdentOccurs);
            if (p.m_PersonIdentityTyp != Pullenti.Ner.Person.Internal.FioTemplateType.Undefined)
            {
                m_PersonIdentityTyp = p.m_PersonIdentityTyp;
            }
            this.CorrectData();
        }
コード例 #2
0
 bool CompareSurnamesPers(PersonReferent p)
 {
     foreach (Pullenti.Ner.Slot a in Slots)
     {
         if (a.TypeName == ATTR_LASTNAME)
         {
             string s = a.Value.ToString();
             foreach (Pullenti.Ner.Slot aa in p.Slots)
             {
                 if (aa.TypeName == a.TypeName)
                 {
                     string ss = aa.Value.ToString();
                     if (this.CompareSurnamesStrs(s, ss))
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
コード例 #3
0
        bool CheckNames(string attrName, PersonReferent p)
        {
            List <string> names1 = new List <string>();
            List <string> inits1 = new List <string>();
            List <string> normn1 = new List <string>();

            foreach (Pullenti.Ner.Slot s in Slots)
            {
                if (s.TypeName == attrName)
                {
                    string n = s.Value.ToString();
                    if (IsInitial(n))
                    {
                        inits1.Add(n);
                    }
                    else
                    {
                        names1.Add(n);
                        string sn = Pullenti.Ner.Core.MiscHelper.GetAbsoluteNormalValue(n, false);
                        if (sn != null)
                        {
                            normn1.Add(sn);
                        }
                    }
                }
            }
            List <string> names2 = new List <string>();
            List <string> inits2 = new List <string>();
            List <string> normn2 = new List <string>();

            foreach (Pullenti.Ner.Slot s in p.Slots)
            {
                if (s.TypeName == attrName)
                {
                    string n = s.Value.ToString();
                    if (IsInitial(n))
                    {
                        inits2.Add(n);
                    }
                    else
                    {
                        names2.Add(n);
                        string sn = Pullenti.Ner.Core.MiscHelper.GetAbsoluteNormalValue(n, false);
                        if (sn != null)
                        {
                            normn2.Add(sn);
                        }
                    }
                }
            }
            if (names1.Count > 0 && names2.Count > 0)
            {
                foreach (string n in names1)
                {
                    if (names2.Contains(n))
                    {
                        return(true);
                    }
                }
                foreach (string n in normn1)
                {
                    if (normn2.Contains(n))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            if (inits1.Count > 0)
            {
                foreach (string n in inits1)
                {
                    if (inits2.Contains(n))
                    {
                        return(true);
                    }
                    foreach (string nn in names2)
                    {
                        if (nn.StartsWith(n))
                        {
                            return(true);
                        }
                    }
                }
            }
            if (inits2.Count > 0)
            {
                foreach (string n in inits2)
                {
                    if (inits1.Contains(n))
                    {
                        return(true);
                    }
                    foreach (string nn in names1)
                    {
                        if (nn.StartsWith(n))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #4
0
        public override bool CanBeGeneralFor(Pullenti.Ner.Referent obj)
        {
            if (!this.CanBeEquals(obj, Pullenti.Ner.Core.ReferentsEqualType.WithinOneText))
            {
                return(false);
            }
            PersonReferent p = obj as PersonReferent;

            if (p == null)
            {
                return(false);
            }
            if (this.FindSlot(ATTR_LASTNAME, null, true) == null || p.FindSlot(ATTR_LASTNAME, null, true) == null)
            {
                return(false);
            }
            if (!this.CompareSurnamesPers(p))
            {
                return(false);
            }
            if (this.FindSlot(ATTR_FIRSTNAME, null, true) == null)
            {
                if (p.FindSlot(ATTR_FIRSTNAME, null, true) != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            if (p.FindSlot(ATTR_FIRSTNAME, null, true) == null)
            {
                return(false);
            }
            if (!this.CheckNames(ATTR_FIRSTNAME, p))
            {
                return(false);
            }
            if (this.FindSlot(ATTR_MIDDLENAME, null, true) != null && p.FindSlot(ATTR_MIDDLENAME, null, true) == null)
            {
                if (!IsInitial(this.GetStringValue(ATTR_FIRSTNAME)))
                {
                    return(false);
                }
            }
            int nameInits  = 0;
            int nameFulls  = 0;
            int secInits   = 0;
            int secFulls   = 0;
            int nameInits1 = 0;
            int nameFulls1 = 0;
            int secInits1  = 0;
            int secFulls1  = 0;

            foreach (Pullenti.Ner.Slot s in Slots)
            {
                if (s.TypeName == ATTR_FIRSTNAME)
                {
                    if (IsInitial(s.Value as string))
                    {
                        nameInits++;
                    }
                    else
                    {
                        nameFulls++;
                    }
                }
                else if (s.TypeName == ATTR_MIDDLENAME)
                {
                    if (IsInitial(s.Value as string))
                    {
                        secInits++;
                    }
                    else
                    {
                        secFulls++;
                    }
                }
            }
            foreach (Pullenti.Ner.Slot s in p.Slots)
            {
                if (s.TypeName == ATTR_FIRSTNAME)
                {
                    if (IsInitial(s.Value as string))
                    {
                        nameInits1++;
                    }
                    else
                    {
                        nameFulls1++;
                    }
                }
                else if (s.TypeName == ATTR_MIDDLENAME)
                {
                    if (IsInitial(s.Value as string))
                    {
                        secInits1++;
                    }
                    else
                    {
                        secFulls1++;
                    }
                }
            }
            if (secFulls > 0)
            {
                return(false);
            }
            if (nameInits == 0)
            {
                if (nameInits1 > 0)
                {
                    return(false);
                }
            }
            else if (nameInits1 > 0)
            {
                if ((secInits + secFulls) > 0)
                {
                    return(false);
                }
            }
            if (secInits == 0)
            {
                if ((secInits1 + secFulls1) == 0)
                {
                    if (nameInits1 == 0 && nameInits > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (secInits1 > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #5
0
        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);
        }