private bool TryFindMatchInMaster(Utakmica u, out int id)
        {
            id = 0;
            List <Tuple <int, string, double> > allDistancesHome    = new List <Tuple <int, string, double> >(100);
            List <Tuple <int, string, double> > allDistancesVisitor = new List <Tuple <int, string, double> >(100);

            foreach (Utakmica utakmicaIzMaster in masterKladionica.SveUtakmice)
            {
                allDistancesHome.Add(new Tuple <int, string, double>(utakmicaIzMaster.Id, utakmicaIzMaster.Domacin, Comparator.LevenshteinDistanceSoft(utakmicaIzMaster.Domacin, u.Domacin)));
                allDistancesVisitor.Add(new Tuple <int, string, double>(utakmicaIzMaster.Id, utakmicaIzMaster.Gost, Comparator.LevenshteinDistanceSoft(utakmicaIzMaster.Gost, u.Gost)));
            }

            PossibleMatch homeMatch = new PossibleMatch()
            {
                MainName = u.Domacin,
                Matches  = allDistancesHome.OrderBy(x => x.Item3).Take(3).ToList()
            };
            PossibleMatch visitorMatch = new PossibleMatch()
            {
                MainName = u.Gost,
                Matches  = allDistancesVisitor.OrderBy(x => x.Item3).Take(3).ToList()
            };

            foreach (var match in homeMatch.Matches)
            {
                Tuple <int, string, double> first = visitorMatch.Matches.FirstOrDefault(x => x.Item1 == match.Item1);
                if (first != null)
                {
                    id = first.Item1;
                }
            }

            return(id > 0);
        }
예제 #2
0
 private bool UtakmicaPostoji(Utakmica utakmica)
 {
     if (sveUtakmice.Where(u => u.Domacin == utakmica.Domacin && u.Gost == utakmica.Gost).Count() > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #3
0
        public void DodajUtakmicuUSortirane(Utakmica u)
        {
            if (sortiraneUtakmice.ContainsKey(u.Id))
            {
                Console.WriteLine(string.Format("Kladionica {0} : Utakmica {1}:{2}-{3} vec postoji.", ime, u.Id, u.Domacin, u.Gost));
                Console.WriteLine(string.Format("Stara vrednost {0}-{1}.", sortiraneUtakmice[u.Id].Domacin, sortiraneUtakmice[u.Id].Gost));
                return;
            }

            sortiraneUtakmice.Add(u.Id, u);
        }
예제 #4
0
        private bool TryParseUtakmicu(string csvLine, out Utakmica utakmica)
        {
            utakmica = null;

            try
            {
                if (string.IsNullOrEmpty(csvLine))
                {
                    return(false);
                }

                double   nulaDvaD;
                double   triPlusD;
                string[] matchValues = csvLine.Split('|');
                string   domacin     = matchValues[0];
                string   gost        = matchValues[1];
                string   nulaDva     = matchValues[2];
                string   triPlus     = matchValues[3];

                if (double.TryParse(nulaDva, out nulaDvaD) && double.TryParse(triPlus, out triPlusD))
                {
                    if (nulaDvaD != 0 && triPlusD != 0)
                    {
                        utakmica = new Utakmica(domacin, gost, nulaDvaD, triPlusD);
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                return(false);
            }
        }
예제 #5
0
 public void DodajUtakmicuUSve(Utakmica u)
 {
     sveUtakmice.Add(u);
 }