コード例 #1
0
        private static bool MatchToPQDamSpecial(string horse_name, string sire_name, int offspring_year_min,
                                                int offspring_year_max, ref string pqid, ref string match_basis)
        {
            foreach (string horse_match_id in pq_horse_lookup[horse_name])
            {
                PQHorse horse_match = pq_horses[horse_match_id];

                if (horse_match.FoalYear == null)
                {
                    continue;
                }

                bool   sires_available = sire_name != null && horse_match.SireName != null;
                double ld_sire         = LD.FuzzyMatch(sire_name, horse_match.SireName);
                bool   sire_match      = ld_sire >= 0.8;

                match_basis = null;
                if (sires_available && sire_match && horse_match.FoalYear <= offspring_year_min - 3 &&
                    horse_match.FoalYear >= offspring_year_max - 28)
                {
                    match_basis = "Dam Special";
                }

                if (match_basis != null)
                {
                    pqid = horse_match.Id;
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        private static bool MatchToPQByName(string horse_name, string sire_name, string dam_name, int?year,
                                            string country, ref string pqid, ref string match_basis)
        {
            foreach (string horse_match_id in pq_horse_lookup[horse_name])
            {
                PQHorse horse_match = pq_horses[horse_match_id];

                bool sires_available = sire_name != null && horse_match.SireName != null;
                bool dams_available  = dam_name != null && horse_match.DamName != null;
                bool years_available = year != null && horse_match.FoalYear != null;

                double ld_sire = LD.FuzzyMatch(sire_name, horse_match.SireName);
                double ld_dam  = LD.FuzzyMatch(dam_name, horse_match.DamName);

                bool sire_match  = ld_sire >= 0.8;
                bool dam_match   = ld_dam >= 0.8;
                bool year_match  = year != null && horse_match.FoalYear != null && year == horse_match.FoalYear;
                bool year_approx = year != null && horse_match.FoalYear != null &&
                                   Math.Abs((int)year - (int)horse_match.FoalYear) <= 3;
                bool country_match = country != null && horse_match.Country != null && country == horse_match.Country;

                match_basis = null;
                if (sires_available && dams_available && years_available && sire_match && dam_match && year_approx)
                {
                    match_basis = "Name, Sire Name, Dam Name, Year";
                }
                else if (!sires_available && dams_available && years_available && dam_match && year_match)
                {
                    match_basis = "Name, Dam Name, Year";
                }
                else if (sires_available && !dams_available && years_available && sire_match && year_match)
                {
                    match_basis = "Name, Sire Name, Year";
                }
                else if (sires_available && dams_available && !years_available && sire_match && dam_match)
                {
                    match_basis = "Name, Sire Name, Dam Name";
                }

                if (match_basis != null)
                {
                    pqid = horse_match.Id;
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        private static bool MatchToPQBySire(string sire_pqid, string horse_name, string sire_name, string dam_name,
                                            int?horse_year, string horse_country, ref string pqid, ref string match_basis)
        {
            if (dam_name == null || horse_year == null)
            {
                return(false);
            }

            List <PQHorse> p_sires = null;

            if (sire_pqid != null)
            {
                p_sires = new List <PQHorse> {
                    pq_horses[sire_pqid]
                };
            }
            else
            {
                p_sires = new List <PQHorse>();
                foreach (string p_sire_id in pq_horse_lookup[sire_name])
                {
                    p_sires.Add(pq_horses[p_sire_id]);
                }
            }

            foreach (PQHorse p_sire in p_sires)
            {
                IEnumerable <string> prog_ids = pq_sire_lookup[p_sire.Id];
                foreach (string prog_id in prog_ids)
                {
                    PQHorse prog = pq_horses[prog_id];
                    double  ld   = LD.FuzzyMatch(horse_name, prog.HorseName);

                    if (prog.DamName != null && prog.FoalYear != null)
                    {
                        double ld_dam = LD.FuzzyMatch(dam_name, prog.DamName);
                        if (ld_dam >= 0.8 && horse_year == prog.FoalYear)
                        {
                            pqid        = prog.Id;
                            match_basis = match_basis + ", Name, Dam Name, Year";
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }