예제 #1
0
        /// <summary>
        /// This function compares dates only by chronological year.
        /// Month and day are not taken into account, the year is compared with the calendar.
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="matchParams"></param>
        /// <returns></returns>
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GEDCOMDateValue date = (GEDCOMDateValue)tag;

            if (IsEmpty() || date.IsEmpty())
            {
                return(0.0f);
            }

            int absVal1 = this.GetChronologicalYear();
            int absVal2 = date.GetChronologicalYear();

            float match   = 0.0f;
            float matches = 0.0f;

            if (absVal1 != 0 && absVal2 != 0)
            {
                matches += 1.0f;
                if (Math.Abs(absVal1 - absVal2) <= matchParams.YearsInaccuracy)
                {
                    match += 100.0f;
                }
            }

            return(match / matches);
        }
예제 #2
0
        public void testIsMatch3()
        {
            var matchParams            = new MatchParams();
            GEDCOMNoteRecord instance1 = (GEDCOMNoteRecord)GEDCOMNoteRecord.Create(null, null, "", "This is a test");
            GEDCOMNoteRecord instance2 = (GEDCOMNoteRecord)GEDCOMNoteRecord.Create(null, null, "", "This is a test");
            float            expResult = 100.0F;
            float            result    = instance1.IsMatch(instance2, matchParams);// TODO matchParams is not used

            Assert.AreEqual(expResult, result, 0.0);
        }
예제 #3
0
        public void testIsMatch()
        {
            var              matchParams = new MatchParams();
            GEDCOMTag        other       = GEDCOMAddress.Create(null, null, "", "");
            GEDCOMNoteRecord instance    = (GEDCOMNoteRecord)GEDCOMNoteRecord.Create(null, null, "", "");
            float            expResult   = 0.0F;
            float            result      = instance.IsMatch(other, matchParams); // TODO matchParams is not used

            Assert.AreEqual(expResult, result, 0.0);
        }
예제 #4
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            GEDCOMNoteRecord note = tag as GEDCOMNoteRecord;

            if (note == null)
            {
                return(0.0f);
            }

            float match = 0.0f;

            if (string.Compare(Note.Text, note.Note.Text, true) == 0)
            {
                match = 100.0f;
            }

            return(match);
        }
예제 #5
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            GEDCOMSourceRecord otherSource = tag as GEDCOMSourceRecord;

            if (otherSource == null)
            {
                return(0.0f);
            }

            float match = 0.0f;

            if (string.Compare(FiledByEntry, otherSource.FiledByEntry, true) == 0)
            {
                match = 100.0f;
            }

            return(match);
        }
예제 #6
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GEDCOMCustomEvent ev = (GEDCOMCustomEvent)tag;

            // match date
            float dateMatch = 0.0f;
            float locMatch  = 0.0f;
            int   matches   = 0;

            GEDCOMDateValue dtVal  = this.Date;
            GEDCOMDateValue dtVal2 = ev.Date;

            matches += 1;
            if (dtVal != null && dtVal2 != null)
            {
                dateMatch = dtVal.IsMatch(dtVal2, matchParams);
            }

            // match location - late code-on by option implementation
            if (matchParams.CheckEventPlaces)
            {
                matches += 1;

                if (this.Place == null && ev.Place == null)
                {
                    locMatch = 100.0f;
                }
                else if (this.Place != null && ev.Place != null && this.Place.StringValue == ev.Place.StringValue)
                {
                    locMatch = 100.0f;
                }
            }

            float match = (dateMatch + locMatch) / matches;

            return(match);
        }
예제 #7
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            GEDCOMFamilyRecord fam = tag as GEDCOMFamilyRecord;

            if (fam == null)
            {
                return(0.0f);
            }

            float match = 0.0f;

            string title1 = GetFamilyString();
            string title2 = fam.GetFamilyString();

            if (string.Compare(title1, title2, true) == 0)
            {
                match = 100.0f;
            }

            return(match);
        }
예제 #8
0
 public virtual float IsMatch(GEDCOMTag tag, MatchParams matchParams)
 {
     return(0.0f);
 }
예제 #9
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            GEDCOMIndividualRecord indi = tag as GEDCOMIndividualRecord;

            if (indi == null)
            {
                return(0.0f);
            }

            if (Sex != indi.Sex)
            {
                return(0.0f);
            }

            bool womanMode = (Sex == GEDCOMSex.svFemale);

            float matchesCount = 0.0f;
            float nameMatch    = 0.0f;
            float birthMatch   = 0.0f;
            float deathMatch   = 0.0f;

            // check name

            /*for (int i = 0; i < indi.PersonalNames.Count; i++)
             *          {
             *                  for (int k = 0; k < fPersonalNames.Count; k++)
             *                  {
             *                          float currentNameMatch = fPersonalNames[k].IsMatch(indi.PersonalNames[i]);
             *                          nameMatch = Math.Max(nameMatch, currentNameMatch);
             *                  }
             *          }*/

            string iName = GetComparableName(womanMode);
            string kName = indi.GetComparableName(womanMode);

            if (!string.IsNullOrEmpty(iName) && !string.IsNullOrEmpty(kName))
            {
                if (matchParams.NamesIndistinctThreshold >= 0.99f)
                {
                    if (iName == kName)
                    {
                        nameMatch = 100.0f;
                    }
                }
                else
                {
                    double sim = IndistinctMatching.GetSimilarity(iName, kName);
                    if (sim >= matchParams.NamesIndistinctThreshold)
                    {
                        nameMatch = 100.0f;
                    }
                }
                matchesCount++;
            }

            // 0% name match would be pointless checking other details
            if (nameMatch != 0.0f && matchParams.DatesCheck)
            {
                var dates     = GetLifeDates();
                var indiDates = indi.GetLifeDates();

                if (dates.BirthEvent != null && indiDates.BirthEvent != null)
                {
                    birthMatch = dates.BirthEvent.IsMatch(indiDates.BirthEvent, matchParams);
                    matchesCount++;
                }
                else if (dates.BirthEvent == null && indiDates.BirthEvent == null)
                {
                    birthMatch = 100.0f;
                    matchesCount++;
                }
                else
                {
                    matchesCount++;
                }

                /*if (death != null && indiDeath != null) {
                 *                      deathMatch = death.IsMatch(indiDeath, matchParams);
                 *                      matches++;
                 *              } else if (death == null && indiDeath == null) {
                 *                      deathMatch = 100.0f;
                 *                      matches++;
                 *              } else {
                 *                      matches++;
                 *              }*/
            }

            float match = (nameMatch + birthMatch + deathMatch) / matchesCount;

            return(match);
        }