Exemplo n.º 1
0
        public static Bet9jaMatches SameMatch(DailyPawaMatches M1, List <Bet9jaMatches> Ms2)
        {
            var bet9jaMatches = Ms2.Where(m => Jobs.SameMatch(m.TeamNames, M1.TeamNames)).ToList();

            if (bet9jaMatches.Count <= 0)
            {
                var timeB9Matches = Ms2.Where(n => DateTime.ParseExact(n.MatchTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture).TimeOfDay.ToString() == M1.TimeOfMatch).ToList();

                var LM = timeB9Matches.Select(m => new B9MatchWithDistance()
                {
                    Distance = ComputeLevenshteinDistance(M1.TeamNames, m.TeamNames),
                    Match    = m
                }).OrderBy(n => n.Distance).ToList();

                if (LM.Count > 0)
                {
                    if (LM[0].Distance <= 10)
                    {
                        return(LM[0].Match);
                    }
                }

                return(null);
            }
            else if (bet9jaMatches.Count == 1)
            {
                return(bet9jaMatches[0]);
            }
            else
            {
                var timeB9Matches = bet9jaMatches.Where(n => DateTime.ParseExact(n.MatchTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture).TimeOfDay.ToString() == M1.TimeOfMatch).ToList();

                if (timeB9Matches.Count == 1)
                {
                    return(timeB9Matches[0]);
                }
                else if (timeB9Matches.Count < 1)
                {
                    return(null);
                }
                else
                {
                    List <int> LevenshteinScores = new List <int>();
                    foreach (var M2 in timeB9Matches)
                    {
                        LevenshteinScores.Add(ComputeLevenshteinDistance(M1.TeamNames, M2.TeamNames));
                    }

                    var i = LevenshteinScores.IndexOf(LevenshteinScores.Min());
                    return(timeB9Matches[i]);
                }
            }
        }
Exemplo n.º 2
0
        public static SportyBetMatches SameMatch(DailyPawaMatches M1, List <SportyBetMatches> Ms2)
        {
            var sportybetMatches = Ms2.Where(m => Jobs.SameMatch(m.TeamNames, M1.TeamNames)).ToList();

            if (sportybetMatches.Count <= 0)
            {
                var timeSbMatches = Ms2.Where(n => n.TimeOfMatch == M1.TimeOfMatch).ToList();

                var LM = timeSbMatches.Select(m => new SbMatchWithDistance()
                {
                    Distance = ComputeLevenshteinDistance(M1.TeamNames, m.TeamNames),
                    Match    = m
                }).OrderBy(n => n.Distance).ToList();

                if (LM.Count > 0)
                {
                    if (LM[0].Distance <= 10)
                    {
                        return(LM[0].Match);
                    }
                }

                return(null);
            }
            else if (sportybetMatches.Count == 1)
            {
                return(sportybetMatches[0]);
            }
            else
            {
                var timeSBMatches = sportybetMatches.Where(n => n.TimeOfMatch == M1.TimeOfMatch).ToList();

                if (timeSBMatches.Count == 1)
                {
                    return(timeSBMatches[0]);
                }
                else if (timeSBMatches.Count < 1)
                {
                    return(null);
                }
                else
                {
                    List <int> LevenshteinScores = new List <int>();
                    foreach (var M2 in timeSBMatches)
                    {
                        LevenshteinScores.Add(ComputeLevenshteinDistance(M1.TeamNames, M2.TeamNames));
                    }

                    var i = LevenshteinScores.IndexOf(LevenshteinScores.Min());
                    return(timeSBMatches[i]);
                }
            }
        }