Пример #1
0
        private void Match()
        {
            var aCol = _bookmakerEvents[Bookmaker.Fonbet];
            var bCol = _bookmakerEvents[Bookmaker.Marathon];

            if (aCol.Count == 0 || bCol.Count == 0)
            {
                return;
            }

            foreach (var a in aCol)
            {
                var match = new SportEventMatch();
                foreach (var b in bCol)
                {
                    if (!EventNameHelper.HaveSameTokens(a.Team1.Tokens, b.Team1.Tokens) ||
                        !EventNameHelper.HaveSameTokens(a.Team2.Tokens, b.Team2.Tokens))
                    {
                        continue;
                    }

                    var distanceTeam1 = EventNameHelper.Levenshtein(a.Team1.Title, b.Team1.Title);
                    var distanceTeam2 = EventNameHelper.Levenshtein(a.Team2.Title, b.Team2.Title);

                    if (distanceTeam1 == 0 || distanceTeam2 == 0)
                    {
                        match.RecognizedSportEvent = b;
                        match.DistanceOfTeam1      = distanceTeam1;
                        match.DistanceOfTeam2      = distanceTeam2;
                        break;
                    }
                }

                if (match.RecognizedSportEvent == null)
                {
                    continue;
                }

                AddToEventAggregator(a, match.RecognizedSportEvent);
            }
        }
Пример #2
0
        public void Levenshtein()
        {
            var result = EventNameHelper.Levenshtein("Брайтон & Хоув Альбион", "Брайтон энд Хоув Альбион");

            Assert.Equal(0, result);
        }