Esempio n. 1
0
        public override float IsMatch(GDMTag tag, MatchParams matchParams)
        {
            GDMIndividualRecord indi = tag as GDMIndividualRecord;

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

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

            bool womanMode = (Sex == GDMSex.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))
            {
                nameMatch = GetStrMatch(iName, kName, matchParams);
                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);
        }