2
from common.combined_classes import TOPIC_GROUPS
3
from common import utils
6
##################################################################################################################
8
##################################################################################################################
11
BINARY_QUESTION_ABOUT_SPORT = ["Do you like sports?", "Do you like fitness?", "Would you like to chat about sport?"]
12
BINARY_QUESTION_ABOUT_ATHLETE = ["Would you like to talk about your favorite athletes? ", "Do you have a sports idol?"]
14
BINARY_QUESTION_ABOUT_COMP = ["Well, Do you want to talk about sports competitions?"]
17
def skill_trigger_phrases():
18
return BINARY_QUESTION_ABOUT_SPORT + BINARY_QUESTION_ABOUT_ATHLETE + BINARY_QUESTION_ABOUT_COMP
21
##################################################################################################################
23
##################################################################################################################
28
DEFAULT_CONFIDENCE = 0.9
36
r"\b(aerobics|archery|badminton|baseball|basketball|beach volleyball|biathlon"
37
r"|billiards|canoe|car race|chess|climb|coach|cricket"
38
r"|curling|cycle|darts|dive|draughts"
39
r"|fence|figure skate|football|golf|gymnastics|handball|hang glide"
40
r"|high jump|hockey|hurdle race|ice rink|in-line skate|jog|judo|karate"
41
r"|long jump|martial arts|motorbike sports|mountaineer|orienteer"
42
r"|parachute|pole-vault|polo|ride|rowing|rugby|ski|snooker"
43
r"|track-and-field|triathlon|tug of war|volleyball|water polo|waterski"
44
r"|weight lift|work out|wrestle|run|swim|tennis|fitness|lacrosse|ballet|soccer)\b"
46
# curling in SPORTS_NO_ING is not a mistake - there is not word to curl
57
"figure skate": "figure skating",
58
"in-line skate": "figure skating",
59
"hang glide": "hand gliding",
60
"high jump": "high jumping",
64
"weight lift": "weight lifing",
65
"wrestle": "wrestling",
66
"work out": "working out",
67
"mountaineer": "mountaineering",
69
"orienteer": "orienteering",
70
"parachute": "parachuting",
71
"pole-vault": "pole-vaulting",
72
"car race": "car racing",
73
"wakeboard": "wakeboarding",
74
"long jump": "long jumping",
76
REVERSE_ING_FORMS = {ING_FORMS[key]: key for key in ING_FORMS}
77
regexp_ing_forms = r"|".join([rf"\b{k}" for k in ING_FORMS.values()])
78
SPORTS = rf"({regexp_ing_forms}|{SPORTS_NO_ING})"
79
KIND_OF_SPORTS_TEMPLATE = re.compile(
83
PASSIVE_SPORT = ["chess", "checkers"]
85
OPINION_ABOUT_PASSIVE_SPORT = [
86
"KIND_OF_SPORT is cool. But since I live in the cloud, I can only play PASSIVE_SPORT!",
87
"I would like to play KIND_OF_SPORT. " "But I have no physical incarnation, so I can only play PASSIVE_SPORT!",
90
KIND_OF_COMPETITION_TEMPLATE = re.compile(
91
r"(FIFA World Cup|Olympic Games|Super Bowl|Grand National"
92
r"|Masters Tournament|Wimbledon|Kentucky Derby|NBA"
93
r"|Cricket World Cup|World Series|Tour De France|March Madness"
94
r"|UEFA|Ryder Cup|Daytona 500|Rugby World Cup"
95
r"|Boston Marathon|Open Championship|Indianapolis 500|Stanley Cup"
96
r"|Monaco Grand Prix|Rose Bowl|UFC|NFL)",
100
ATHLETE_TEMPLETE = re.compile(
101
r"(athlete|sportsperson|games player|muscle person|player" r"|footballer|aquanaut|diver|jock|lifter)", re.IGNORECASE
103
SPORT_TEMPLATE = re.compile(r"(sport|active)", re.IGNORECASE)
104
SUPPORT_TEMPLATE = re.compile(r"(support|a fan of)", re.IGNORECASE)
106
QUESTION_TEMPLATE = re.compile(r"(what|did|do|which|who) (team )?(you )?(do|is|are|kind of|know|like)", re.IGNORECASE)
108
LIKE_TEMPLATE = re.compile(r"(like|love|support|a fan of|favorite|enjoy|want to talk)?", re.IGNORECASE)
110
HATE_TEMPLATE = re.compile(r"(hate)", re.IGNORECASE)
112
COMPETITION_TEMPLATE = re.compile(r"(tournament|tourney|competition|championship|derby)", re.IGNORECASE)
114
OFFER_FACT_COMPETITION = [
115
"I recently wandered on the Internet and found an interesting fact about COMPETITION." "Do you want to hear?",
116
"Cool! Do you want to hear a fact about COMPETITION?",
117
"I know something interesting about it. Do you want me to share a fact about COMPETITION?",
119
OPINION_REQUESTS = ["What do you think about it?", "It's interesting, isn't it?", "What is your view on it?"]
121
ASK_ABOUT_ATH_IN_KIND_OF_SPORT = [
122
"Yep, that's cool. I'm really wondering who is your idol in KIND_OF_SPORT?",
123
"Wow, that's cool. Who is your favorite athlete in KIND_OF_SPORT?",
126
OPINION_ABOUT_ATHLETE_WITH_TEAM_AND_POS = [
127
"Oh, I know this POSITION from TEAM. He does his job well.",
128
"Oh, I kind of know him. He is a POSITION and plays in TEAM.",
131
OPINION_ABOUT_ATHLETE_WITH_TEAM = [
132
"Oh yes, he's cool. I've seen him perform miracles in TEAM.",
133
"Oh, he's just a wizard. He does his job well in TEAM.",
136
OPINION_ABOUT_ATHLETE_WITHOUT_TEAM = ["I know NAME. He's kind of from COUNTRY. Have you ever been in COUNTRY?"]
138
OPINION_ABOUT_TEAM = ["By the way, I support the TEAM. I remember how they won in COMPETITION. It was cool."]
140
LAST_CHANCE_TEMPLATE = [
141
"I'm still too young and I don't know much, but something tells me that It's very interesting. "
142
"Tell me more about that",
143
"Oh, this is the first time I hear about this. " "Tell me more about that",
144
"This is probably very interesting. Tell me more about that.",
148
def about_sport(annotated_utterance):
149
found_topics = utils.get_topics(annotated_utterance, probs=False, which="all")
150
if any([topic in found_topics for topic in TOPIC_GROUPS["sport"]]):
152
elif re.findall(KIND_OF_SPORTS_TEMPLATE, annotated_utterance["text"]):
154
elif re.findall(KIND_OF_COMPETITION_TEMPLATE, annotated_utterance["text"]):