Beispiel #1
0
        void AddToEventAggregator(RecognizedSportEvent recSportEvent1, RecognizedSportEvent recSportEvent2)
        {
            var id         = EventNameHelper.GetEventId(recSportEvent1.SportEvent);
            var aggregator = _EventAggregators.FirstOrDefault(u => u.Id == id);

            if (aggregator != null)
            {
                aggregator.RecognizedSportEvents.RemoveAll(
                    u => u.SportEvent.Bookmaker == recSportEvent1.SportEvent.Bookmaker ||
                    u.SportEvent.Bookmaker == recSportEvent2.SportEvent.Bookmaker);

                aggregator.RecognizedSportEvents.Add(recSportEvent1);
                aggregator.RecognizedSportEvents.Add(recSportEvent2);

                return;
            }

            var newAggregator = new EventAggregator(id)
            {
                Sport = Sport.Soccer,
                RecognizedSportEvents = new List <RecognizedSportEvent>
                {
                    recSportEvent1,
                    recSportEvent2
                },
                Team1 = recSportEvent1.Team1.Title,
                Team2 = recSportEvent1.Team2.Title,
            };

            _EventAggregators.Add(newAggregator);
        }
Beispiel #2
0
 public void DiceCoefficient()
 {
     Assert.Equal(1, EventNameHelper.DiceCoefficient("Брайтон & Хоув Альбион", "Брайтон энд Хоув Альбион"));
     //Assert.Equal(1, EventNameHelper.DiceCoefficient("Прима", "Примадонна")); //0.615384615384615
     //Assert.Equal(1, EventNameHelper.DiceCoefficient("Прима", "Прима"));
     //Assert.Equal(1, EventNameHelper.DiceCoefficient("Прима", "Прима"));
 }
Beispiel #3
0
        public void Test()
        {
            var container   = EventAggregatorContainer.Instance;
            var sportEvent1 = new SportEvent
            {
                Bookmaker   = Bookmaker.Fonbet,
                TitleOrigin = "Калуга U17 — Ротор-Волгоград U17",
                Id          = "123123"
            };

            var sportEvent2 = new SportEvent
            {
                Bookmaker   = Bookmaker.Marathon,
                TitleOrigin = "Калуга до 17 - Ротор до 17",
                Id          = "444555"
            };

            container.AddEvents(new SportEvent[] { sportEvent1 });
            container.AddEvents(new SportEvent[] { sportEvent2 });

            var aggregator = container.GetEventAggregator(EventNameHelper.GetEventId(sportEvent1));

            Assert.NotNull(aggregator);

            Assert.Equal("Калуга", aggregator.Team1);
            Assert.Equal("Ротор-Волгоград", aggregator.Team2);
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
        public void Levenshtein()
        {
            var result = EventNameHelper.Levenshtein("Брайтон & Хоув Альбион", "Брайтон энд Хоув Альбион");

            Assert.Equal(0, result);
        }