formatted_title = self.bet_title.lower() formatted_title = ' '.join(formatted_title.split()) formatted_title = formatted_title.strip() return formatted_title def _format_after(self, bets): return bets def _format_teams(self): return self._move_teams_left() def _format_uncommon_chars(self): formatted_title = self.bet_title.lower() # these are different characters :) formatted_title = formatted_title.replace('с', 'c') formatted_title = formatted_title.replace('–', '-') return formatted_title if __name__ == '__main__': formatter = FootballOneXBetSyntaxFormatter() sport = Sport.from_dict(one_x_bet.sport) formatted_sport = formatter.apply_unified_syntax_formatting(sport) print(formatted_sport) my_path = os.path.abspath(os.path.dirname(__file__)) path = my_path + '\\sample_data\\one_x_bet.py' with open(path, 'w', encoding='utf-8') as f: print('sport =', formatted_sport, file=f)
bets = self._update(bets, self._move_teams_left) return bets def _fix_total_rounds_and_maps(self): # Если захочешь, перепишешь по-другому, мне было проще так, вдруг мы потом решим опять менять вид total maps formatted_title = self.bet_title.lower() match = re.search('^total — (even|odd)', formatted_title) if match: formatted_title = formatted_title.replace('total —', 'total maps') match = re.search('^total (over|under)', formatted_title) if match: formatted_title = formatted_title.replace('total', 'total maps') match1 = re.search(r'map: .+? total', formatted_title) match2 = re.search(r'map: total', formatted_title) # не знаю как это в одно запихнуть ))))00)) if match1 or match2: formatted_title = formatted_title.replace('total', 'total rounds') return formatted_title if __name__ == '__main__': formatter = CSGOParimatchSyntaxFormatter() sport = Sport.from_dict(parimatch.sport) formatted_sport = formatter.apply_unified_syntax_formatting(sport) print(formatted_sport) my_path = os.path.abspath(os.path.dirname(__file__)) path = my_path + '\\sample_data\\parimatch.py' with open(path, 'w', encoding='utf-8') as f: print('sport =', formatted_sport, file=f)
return formatted_title def _format_first_to_win_number_of_rounds(self): formatted_title = self.bet_title.lower() if 'race to rounds' in formatted_title: formatted_title = formatted_title.replace('race to rounds ', '') words = re.split(' ', formatted_title) formatted_title = '' for i in range(0, len(words) - 1): formatted_title += words[i] + ' ' formatted_title += 'will be first to win ' + words[-1] + ' rounds' return formatted_title def _format_handicap(self): formatted_title = GSF._format_handicap(self) if 'handicap' in formatted_title and ' maps' not in formatted_title: formatted_title += ' rounds' return formatted_title if __name__ == '__main__': formatter = CSGOGGBetSyntaxFormatter() sport = Sport.from_dict(ggbet.sport) formatted_sport = formatter.apply_unified_syntax_formatting(sport) print(formatted_sport) my_path = os.path.abspath(os.path.dirname(__file__)) path = my_path + '\\sample_data\\ggbet.py' with open(path, 'w', encoding='utf-8') as f: print('sport =', formatted_sport, file=f)
return formatted_title def _format_map_duration(self): formatted_title = self.bet_title.lower() if 'map duration' in formatted_title: formatted_title = formatted_title.replace('map duration', 'duration') formatted_title = formatted_title.replace(' minutes', '') return formatted_title def _format_first_to_destroy(self): formatted_title = self.bet_title.lower() if 'which team will be the first to lose a turret?' in formatted_title: formatted_title = formatted_title.replace('which team will be the first to lose a turret?', 'will first destroy turret') formatted_title = self.swap_teams(formatted_title) return formatted_title def _format_teams(self): return self._move_teams_left() if __name__ == '__main__': formatter = LoLFavoritSyntaxFormatter() sport = Sport.from_dict(favorit.sport) formatted_sport = formatter.apply_unified_syntax_formatting(sport) print(formatted_sport) my_path = os.path.abspath(os.path.dirname(__file__)) path = my_path + '\\sample_data\\favorit.py' with open(path, 'w', encoding='utf-8') as f: print('sport =', formatted_sport, file=f)
def test_favorit_unified_syntax_formatting(self): sport = Sport.from_dict(self.favorit_dota_dict) sport = self.favorit_syntax_formatter.apply_unified_syntax_formatting( sport) self._test_unified_syntax_formatting(sport)
def test_marathon_unified_syntax_formatting(self): sport = Sport.from_dict(self.marathon_dota_dict) sport = self.marathon_syntax_formatter.apply_unified_syntax_formatting( sport) self._test_unified_syntax_formatting(sport)
from groupers.esports.esports_fork_grouper import EsportsForkGrouper class LoLForkGrouper(EsportsForkGrouper): _grouped_by = { r'(^\d-(st|nd|rd|th) map: )?(total (kills|dragons|barons|turrets|inhibitors)|duration) (over|under) (\d+(' r'\.\d)?)$': (3, 6), r'(^\d-(st|nd|rd|th) map: )?(total kills) (even|odd)$': (3, ), r'(^\d-(st|nd|rd|th) map: ).+? (most kills)$': (3, ), r'(^\d-(st|nd|rd|th) map: ).+? (will first (kill (baron|dragon)|destroy (turret|inhibitor)))$': (3, ), r'(^\d-(st|nd|rd|th) map: ).+? (first blood|will make kill \d+)$': (3, ), r'(^\d-(st|nd|rd|th) map: ).+? (will first make \d+ kills)$': (3, ), } def _get_grouped_by(self) -> dict: result = dict(LoLForkGrouper._grouped_by) result.update(EsportsForkGrouper._get_grouped_by(self)) return result def _get_handicap_targets(self): return EsportsForkGrouper._get_handicap_targets(self) + ['kills'] if __name__ == '__main__': grouper = LoLForkGrouper() lol = Sport.from_dict(favorit_lol_dict) grouped_lol = grouper.group_bets(lol) print(grouped_lol)
def test_parimatch_unified_syntax_formatting(self): sport = Sport.from_dict(self.parimatch_dota_dict) sport = self.parimatch_syntax_formatter.apply_unified_syntax_formatting( sport) self._test_unified_syntax_formatting(sport)
return formatted_title def _format_first_kill(self): formatted_title = self.bet_title.lower() if 'first blood' in formatted_title: formatted_title = formatted_title.replace('1st team to ', '') formatted_title = formatted_title.replace(' first blood', '') formatted_title += ' first blood' return formatted_title def _format_map_duration(self): formatted_title = self.bet_title.lower() if 'map duration' in formatted_title: formatted_title = formatted_title.replace('map duration', 'duration') formatted_title = formatted_title.replace(' minutes', '') return formatted_title def _format_teams(self): formatted_title = self._move_teams_left() return formatted_title if __name__ == '__main__': formatter = DotaMarathonSyntaxFormatter() sport = Sport.from_dict(marathon.sport) formatted_sport = formatter.apply_unified_syntax_formatting(sport) print(formatted_sport) my_path = os.path.abspath(os.path.dirname(__file__)) path = my_path + '\\sample_data\\marathon.py' with open(path, 'w', encoding='utf-8') as f: print('sport =', formatted_sport, file=f)
from groupers.esports.esports_fork_grouper import EsportsForkGrouper class DotaForkGrouper(EsportsForkGrouper): _grouped_by = { r'(^\d-(st|nd|rd|th) map: )?(total (kills|roshans)|duration) (over|under) (\d+(\.\d)?)$': (3, 5), r'(^\d-(st|nd|rd|th) map: )?(total kills) (even|odd)$': (3, ), r'(^\d-(st|nd|rd|th) map: )(megacreeps) (yes|no)$': (3, ), r'(^\d-(st|nd|rd|th) map: ).+? (will first (kill roshan|lose barracks|destroy tower))$': (3, ), r'(^\d-(st|nd|rd|th) map: ).+? (first blood|will make kill \d+)$': (3, ), r'(^\d-(st|nd|rd|th) map: ).+? (will first make \d+ kills)$': (3, ), } def _get_grouped_by(self) -> dict: result = dict(DotaForkGrouper._grouped_by) result.update(EsportsForkGrouper._get_grouped_by(self)) return result def _get_handicap_targets(self): return EsportsForkGrouper._get_handicap_targets(self) + ['kills'] if __name__ == '__main__': grouper = DotaForkGrouper() dota = Sport.from_dict(marathon_dota_dict) grouped_dota = grouper.group_bets(dota) print(grouped_dota)
def test_ggbet_unified_syntax_formatting(self): sport = Sport.from_dict(self.ggbet_csgo_dict) sport = self.ggbet_syntax_formatter.apply_unified_syntax_formatting( sport) self._test_unified_syntax_formatting(sport)
def test_one_x_bet_unified_syntax_formatting(self): sport = Sport.from_dict(self.one_x_bet_lol_dict) sport = self.one_x_bet_syntax_formatter.apply_unified_syntax_formatting( sport) self._test_unified_syntax_formatting(sport)
class FootballForkGrouper(ForkGrouper, ABC): _grouped_by = { r'^(\d-(st|nd|rd|th) half )?.+? will (win)$': (3, ), r'^(\d-(st|nd|rd|th) half )?(draw) will (win|lose)$': (3, ), r'^(\d-(st|nd|rd|th) half )?((.+? )?(asian )?total (goals|yellow cards|corners)) (over|under) (\d+(\.\d{1,' r'2})?)$': (3, 8), r'^(\d-(st|nd|rd|th) half )?(total goals|) (even|odd)$': (3, ), r'^(\d-(st|nd|rd|th) half: )(correct score) \d+-\d+$': (3, ), } def _get_handicap_targets(self) -> list: return ['goals', 'corners', 'yellow cards'] def _get_handicap_pattern_prefix(self) -> str: return r'^((?P<prefix>\d-(st|nd|rd|th) half )?(?P<team_name>.+?) ' \ r'(asian )?handicap (?P<sign>\+|-|)(\d+(\.\d{1,2})?) (' def _get_grouped_by(self) -> dict: result = dict(FootballForkGrouper._grouped_by) result.update(ForkGrouper._get_grouped_by(self)) return result if __name__ == '__main__': grouper = FootballForkGrouper() football = Sport.from_dict(ggbet_football_dict) for match in football: grouper.group_bets(match) print(football)