diff --git a/.DS_Store b/.DS_Store index 0d09fce..f0552a8 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/hw_lexicon_entity_matching.py b/hw_lexicon_entity_matching.py index 70bfded..8adca84 100644 --- a/hw_lexicon_entity_matching.py +++ b/hw_lexicon_entity_matching.py @@ -18,7 +18,9 @@ class State(Enum): TURN0DK1U = auto() TURN0ERR = auto() TURNTRADE1S = auto() + TURNTRADE1S1 = auto() TURNTRADE1U = auto() + TURNTRADE0ERR = auto() TURNTRADE1ERR = auto() TURNTRADE1BS = auto() TURNTRADE1BU = auto() @@ -45,8 +47,11 @@ class State(Enum): TURNPF1S = auto() TURNPF1U = auto() TURNPF1ERR = auto() + TURNPF1ERRU = auto() + TURNPF1ERR1S = auto() TURNPF2AS = auto() TURNPF2AU = auto() + TURNPF2A_DK = auto() TURNPF2BS = auto() TURNPF2BS1 = auto() TURNPF2BU1 = auto() @@ -253,12 +258,12 @@ def run (self, ngrams, vars, args): return "I found this most recent trade news that {} from {} is going to {}".format(player, givingTeam, receivingTeam) -class tradeNews(Macro): +class tradeNews(Macro): #this won't run because the range is changed due to change in json def run (self, ngrams, vars, args): with open('trades.json') as f: data = json.load(f) trades = data['trades'] - trade = trades[randrange(55)]['TRANSACTION_DESCRIPTION'] + trade = trades[randrange(len(trades))]['TRANSACTION_DESCRIPTION'] receivingTeam = trade.split(' received')[0] givingTeam = trade.split('from ')[1] givingTeam = givingTeam[:-1] @@ -280,7 +285,7 @@ def run (self, ngrams, vars, args): #print(player) #print(role) - return "I found this most recent trade news that {} from {} is going to {}".format(player, givingTeam, receivingTeam) + return "{} from {} went to {}".format(player, givingTeam, receivingTeam) class tradeNewsByTeam(Macro): def run (self, ngrams, vars, args): @@ -315,7 +320,7 @@ def run (self, ngrams, vars, args): #print(player) #print(role) - return "I found this most recent trade news that {} from {} is going to {}".format(player, givingTeam, receivingTeam) + return "{} from {} went to {}".format(player, givingTeam, receivingTeam) class goodBadTrade(Macro): @@ -368,7 +373,8 @@ def run (self, ngrams, vars, args): for i in range(2): s += n[0][i] s += "01" - if (n[0] == "Marcus" and n[1] == "Morris"): playerid = "morrima02" + playerid = s.lower() + #if (n[0] == "Marcus" and n[1] == "Morris"): playerid = "morrima02" player = Player(playerid) position = player.position exp = player.games_played @@ -478,61 +484,76 @@ def run (self, ngrams, vars, args): possible_results = '[{' \ 'better,worse,obliterate,crush,destroy,change,effect,difference,improve,adjust,adapt,implications,good,bad,weird' \ '}]' +end = '[{'\ + 'end,stop,terminate,cease'\ + '}]' + +proceed = '[{'\ + 'keep,continue,proceed,go on,carry on'\ + '}]' """playoffs turns""" #turn 1 -df.add_system_transition(State.START, State.TURNPF1U, r'[! "Hi I am NBA chatbot. The NBA season has been shutdown because of COVID. If we played playoffs based off the current standings, which team do you think would win?"]') +df.add_system_transition(State.START, State.TURNPF1U, r'[! "Hi I am NBA chatbot. The NBA season has been" {shutdown,suspended,put on hold} "because of COVID. ' + r' If we played playoffs" {just based off the current standings,today,right now} "though, which team do you think would win?"]') df.add_user_transition(State.TURNPF1U, State.TURNPF2AS, dont_know) df.add_user_transition(State.TURNPF1U, State.TURNPF2CS, '[#ONT(nonplayoffteams)]') df.add_user_transition(State.TURNPF1U, State.TURNPF2BS, '[$favUserTeam=#ONT(playoffteams)]') -df.set_error_successor(State.TURNPF1U, State.TURNPF1ERR) -df.add_system_transition(State.TURNPF1ERR, State.TURNPF2AS, 'Picking userTeam') +df.set_error_successor(State.TURNPF1U, State.TURNPF1ERR) +df.add_system_transition(State.TURNPF1ERR, State.TURNPF1ERRU, r'[! "Hmm, I dont think that is an NBA team. Do you want to keep talking? ' + r'We can either stop the conversation here and talk about something else, or I can keep on talking with you about a team that I think can win!"]') +df.add_user_transition(State.TURNPF1ERRU, State.END, end) +df.add_user_transition(State.TURNPF1ERRU, State.TURNPF1ERR1S, proceed) +df.add_system_transition(State.TURNPF1ERR1S, State.TURNPF2AU, r'[! #botFavTeam "Okay! I hope this will still be fun. I think that" $favSysTeam "can win the playoffs even with the unpredictability of the whole thing. What do you think?"]') -#idk scenario +#idk scenario df.add_system_transition(State.TURNPF2CS, State.TURNPF2AU, r'[! #botFavTeam "I dont think that team will be in the playoffs. But you know, I think that " $favSysTeam " can win. Do you agree?"]') df.add_system_transition(State.TURNPF2AS, State.TURNPF2AU, r'[! #botFavTeam "It is okay to be unsure because predictability of playoffs is difficult without more data. I think that " $favSysTeam " can win. Do you agree?"]') df.add_user_transition(State.TURNPF2AU, State.TURNPF3AS, '[#ONT(agree)]') #can probably have a turn in here which catches the user saying another team, that will handle implicit no df.add_user_transition(State.TURNPF2AU, State.TURNPF3BS, '[#ONT(disagree)]') +df.add_user_transition(State.TURNPF2AU, State.TURNPF2A_DK, dont_know) df.set_error_successor(State.TURNPF2AU, State.TURNPF2AERR) -df.add_system_transition(State.TURNPF2AERR, State.TURNPF3AS, 'uncertain about playoff team') +df.add_system_transition(State.TURNPF2AERR, State.TURNPF5U, r'[! "Thats an interesting take for sure. Personally, I think" $favSysTeam "will win because of" $favSysPlayer ". What do you think of" $favSysPlayer "?"]') +df.add_system_transition(State.TURNPF2A_DK, State.TURNPF5U, r'[! "Oh, are you not sure? Personally, I think" $favSysTeam "will win because of" $favSysPlayer ". What do you think of" $favSysPlayer "?"]') df.add_system_transition(State.TURNPF3AS, State.TURNPF3AU, r'[! "I always love meeting other fans of " $favSysTeam " Why do you think " $favSysTeam " is going to win?"]') df.add_system_transition(State.TURNPF3BS, State.TURNPF3AU, r'[! "Why do you think " $favSysTeam " will not win?"]') df.add_user_transition(State.TURNPF3AU, State.TURNPF4S, '[/[a-z A-Z]+/]') #pull any response here #this state throws an error because comparePlayers (or new Macro) needs to be able to work without having user input -df.add_system_transition(State.TURNPF4S, State.TURNPF5U, r'[! "That is a good opinion. Personally, I think " $favSysTeam "will win because of " $favSysPlayer ". What do you think of " $favSysPlayer "?"]') #todo modify comparePlayer to work with either sysplayer or userplayer +df.add_system_transition(State.TURNPF4S, State.TURNPF5U, r'[! "That is a good opinion. Personally, I think " $favSysTeam "will win because of " $favSysPlayer ". What do you think of " $favSysPlayer "?"]') #error transition for turn 3 -#df.set_error_successor(State.TURNPF3AU, State.TURNPF3AERR) -#df.add_system_transition(State.TURNPF3AERR, State.TURN) +df.set_error_successor(State.TURNPF3AU, State.TURNPF3AERR) +df.add_system_transition(State.TURNPF3AERR, State.TURNPF5U, r'[! "That is a good opinion. Personally, I think " $favSysTeam "will win because of " $favSysPlayer ". What do you think of " $favSysPlayer "?"]') + # Playoff Turn 2 (not idk scenario) df.add_system_transition(State.TURNPF2BS, State.TURNPF2BU, r'[! #botFavTeam "Why do you think" $favUserTeam "will win?"]') -df.add_user_transition(State.TURNPF2BU, State.TURNPF2BS1, '[$rationale=[#ONT(rationale)]]') # can change it to pick up a specific player too but again, needs to make sure player is actually on that team +df.add_user_transition(State.TURNPF2BU, State.TURNPF2BS1, '[$rationale=[#ONT(rationale)]]') #?? can change it to pick up a specific player too but again, needs to make sure player is actually on that team df.set_error_successor(State.TURNPF2BU, State.TURNPF2BU_ERR2) -df.add_system_transition(State.TURNPF2BU_ERR2, State.TURNPF3U, r'[! "Thats fair. Personally, I think that the" $favSysTeam "have the best chance of winning because of" $favSysPlayer]') #todo make sure this transition goes into the correct user transition +df.add_system_transition(State.TURNPF2BU_ERR2, State.TURNPF3U, r'[! "Thats fair. Personally, I do not think that " $favUserTeam "is that good. I think that the" $favSysTeam "have the best chance of winning because of" $favSysPlayer]') #todo make sure this transition goes into the correct user transition #ANDREW - System dosen't ask question, as a user idk how to respond to "Thats fair. Personally, I think that Bucks has the best chance of winning because of Giannis Antetokounmpo" df.add_system_transition(State.TURNPF2BS1, State.TURNPF2BU1, r'[! "Do you think there is a player that is integral to their team?"]') df.add_user_transition(State.TURNPF2BU1, State.TURNPF3CS, '[$favUserPlayer=[#ONT(playoffteams)]]') #todo make ontology for players who are in and not in playoffs and need to match it to make sure the player is actually on the team df.set_error_successor(State.TURNPF2BU1, State.TURNPF2BU_ERR2) -#df.add_system_transition(State.TURNPF2BU_ERR2, State.TURNPFU, r'[! "Thats fair. Personally, I think that" $favSysTeam "has the best chance of winning because of" $favSysPlayer]') +df.add_system_transition(State.TURNPF2BU_ERR2, State.TURNPF5U, r'[! "Thats fair. Personally, I think that" $favSysTeam "has the best chance of winning because of" $favSysPlayer ". He is my hometown hero. What do you think of Kawhi Leonard?"]') # Playoff Turn 3 df.add_system_transition(State.TURNPF3CS, State.TURNPF3U, r'[! "I think that it is " #comparePlayers ". What is your opinion?"]') -df.add_user_transition(State.TURNPF3U, State.TURNTRADE0S, "[#ONT(rationale)]") #need to add another way to transition to the trades here - +df.add_user_transition(State.TURNPF3U, State.TURNTRADE0S, "[$teamRationale=[#ONT(rationale)]]") #need to add another way to transition to the trades here +df.add_user_transition(State.TURNPF3U, State.TURNTRADE0AS, '[/[a-z A-Z]+/]') df.add_user_transition(State.TURNPF5U, State.TURNTRADE0AS, '[/[a-z A-Z]+/]') """trades turns""" #turn 0 -#todo need to run trade macro up here to get the trades specific to teams #TURNPF5S comes from the idk scenario. will probably need to add in some things to engage more with user response, this is generic catcher -df.add_system_transition(State.TURNTRADE0AS, State.TURNTRADE0U, r'[! "Fair enough. Earlier in the season " #tradeNewsByTeam]') #I heard that" $receivingTeam "had traded for " $player ". Do you think that trade had repercussions for playoffs?"]') -df.add_system_transition(State.TURNTRADE0S, State.TURNTRADE0U, r'[! "Earlier in the season I heard that" #tradeNewsByTeam ". Do you think that trade had repercussions for playoffs?"]') -df.add_user_transition(State.TURNTRADE0U, State.TURNTRADE1S, "[#ONT(agree)]") +df.add_system_transition(State.TURNTRADE0AS, State.TURNTRADE0U, r'[! "Fair enough. Earlier in the season " #tradeNews() ". do you think this impacted or will impact playoffs in any way?"]') +df.add_system_transition(State.TURNTRADE0S, State.TURNTRADE0U, r'[! "Earlier in the season I heard that" #tradeNews() ". Do you think that trade will have impact for playoffs?"]') +df.add_user_transition(State.TURNTRADE0U, State.TURNTRADE1S, "[!#ONT(agree)]") +df.add_user_transition(State.TURNTRADE0U, State.TURNTRADE1S1, "[!#ONT(disagree)]") #df.add_user_transition(State.TURNTRADE0U, State.TURNTRADE1S, "[ONT(disagree)]") df.add_user_transition(State.TURNTRADE0U, State.TURN0DK1S, dont_know) df.add_system_transition(State.TURN0DK1S, State.TURN0DK1U, r'[! "No worries, if you dont know, I can just talk about trades! Is that okay?"]') @@ -546,6 +567,33 @@ def run (self, ngrams, vars, args): #df.add_system_transition(State.TURNTRADE1S2, State.EARLYEND, r'[! "Oh, thats a shame. I cant really talk about other news right now unfortunately. Maybe next time we can talk some more"]') +#turn 1 +df.add_system_transition(State.TURNTRADE1S, State.TURNTRADE1U, r'[! "ok then. lets talk about $player." #playerRating() " What do you think about him?"]') #r'[!{#tradeNews()} . Do you want to talk about this trade?"]' +df.add_system_transition(State.TURNTRADE1S1, State.TURNTRADE1U, r'[! "ok then. lets talk about $player." #playerRating() " What do you think about him?"]') +df.add_user_transition(State.TURNTRADE1U, State.TURNTRADE2S, '[#ONT(agree)]') +df.add_user_transition(State.TURNTRADE1U, State.TURNTRADE1BS, '[#ONT(disagree)]') +df.add_system_transition(State.TURNTRADE1BS, State.TURNTRADE1BU, r'[! "We can also talk about all-stars, injuries, the draft, or stop talking. Which would you prefer?"]') +df.add_user_transition(State.TURNTRADE1BU, State.END, '[/[a-z A-Z]+/]') +df.set_error_successor(State.TURNTRADE1U, State.TURNTRADE1ERR) +df.add_system_transition(State.TURNTRADE1ERR, State.TURNTRADE2U, r'[! "Okay, I mean " $player " is really interesting, and I really want to talk about him. " #playerRating() " What do you think about him?"]' ) + + +#turn 2 +df.add_system_transition(State.TURNTRADE2S, State.TURNTRADE2U, r'[! "When I watch " $player ", " #playerRating() " What do you think about " $player "?"]') +df.add_user_transition(State.TURNTRADE2U, State.TURNTRADE3S1, "[$response2=#POS(adj)]") +df.add_user_transition(State.TURNTRADE2U, State.TURNTRADE3S2, "[$response2=#POS(verb)]") +df.add_user_transition(State.TURNTRADE2U, State.TURNTRADE2DK1S, dont_know) # dont knows +df.add_system_transition(State.TURNTRADE2DK1S, State.TURNTRADE3U, r'[! "Its okay if youre not sure! I actually think that " #goodBadTrade() ". Do you agree?"]') +df.set_error_successor(State.TURNTRADE2U, State.TURNTRADE2ERR) +df.add_system_transition(State.TURNTRADE2ERR, State.TURNTRADE3U, r'[! "I dont know why you made that comment about " $player ". I still think that " ' + r'#goodBadTrade() ". Do you agree?"]') +#need to revise this trade turn +df.add_system_transition(State.TURN0ERR, State.TURN0, r'[! "I do not know how to talk about that yet"]') +df.set_error_successor(State.TURN0, State.TURN0ERR) +df.add_system_transition(State.TURN0ERR, State.TURNTRADE1U, r'[! "Honestly, Im only really good at talking about trades right now. If thats okay then listen to this! " #tradeNews() ". Doesnt that sound interesting?"]') +#df.add_system_transition(State.TURNTRADE1S2, State.EARLYEND, r'[! "Oh, thats a shame. I cant really talk about other news right now unfortunately. Maybe next time we can talk some more"]') + + #turn 1 df.add_system_transition(State.TURNTRADE1S, State.TURNTRADE1U, r'[!{#tradeNews()} ". Do you want to talk about this trade?"]') df.add_user_transition(State.TURNTRADE1U, State.TURNTRADE2S, '[#ONT(agree)]') diff --git a/teams.json b/teams.json index 627924c..0e2f16b 100644 --- a/teams.json +++ b/teams.json @@ -1843,7 +1843,8 @@ "do", "of course", "sure", - "cool" + "cool", + "too" ], "disagree": [ "no", @@ -1879,7 +1880,10 @@ "blocks", "field goals", "three", - "fouls" + "fouls", + "good", + "bad", + "potential" ] } } \ No newline at end of file diff --git a/trades.json b/trades.json index 7df3628..1b9876f 100644 --- a/trades.json +++ b/trades.json @@ -9,15 +9,6 @@ "Additional_Sort": 1610612755, "GroupSort": "Trade 2019095" }, - { - "Transaction_Type": "Trade", - "TRANSACTION_DATE": "2020-02-06T00:00:00", - "TRANSACTION_DESCRIPTION": "Minnesota Timberwolves received guard D'Angelo Russell from Golden State Warriors.", - "TEAM_ID": 1610612750, - "PLAYER_ID": 1626156, - "Additional_Sort": 1610612744, - "GroupSort": "Trade 2019096" - }, { "Transaction_Type": "Trade", "TRANSACTION_DATE": "2020-02-06T00:00:00", @@ -108,15 +99,6 @@ "Additional_Sort": 1610612752, "GroupSort": "Trade 2019102" }, - { - "Transaction_Type": "Trade", - "TRANSACTION_DATE": "2020-02-06T00:00:00", - "TRANSACTION_DESCRIPTION": "LA Clippers received guard Isaiah Thomas from Washington Wizards.", - "TEAM_ID": 1610612746, - "PLAYER_ID": 202738, - "Additional_Sort": 1610612764, - "GroupSort": "Trade 2019102" - }, { "Transaction_Type": "Trade", "TRANSACTION_DATE": "2020-02-05T00:00:00",