async def on_message(message): if message.author == client.user: return if message.content.startswith('!'): user_input = message.content[1:] if '?' in message.content: ran = random.randint(0, 2) await message.channel.send(question[ran] + message.author.mention) else: response = counter_argument(user_input, dataframe) await message.channel.send(response[0] + message.author.mention) if '(No pro/con arg)' in response[1]: emoji = '\U0001f44d' await message.add_reaction(emoji) print(response[1])
def main(): # Check if database with claims and counterarguments and bert embeddings already been created, otherwise create. if os.path.isfile('embeddings_df.pkl'): dataframe = pd.read_pickle('embeddings_df.pkl') else: if os.path.isfile('Pickles/Trolley.pkl'): dataframe = pd.read_pickle('Pickles/trolley.pkl') else: create_dataframe() dataframe = pd.read_pickle('Pickles/trolley.pkl') bert_encoding(dataframe) embeddings = pd.read_pickle('embeddings_df.pkl') if os.path.isfile('embeddings_df2.pkl'): dataframe2 = pd.read_pickle('embeddings_df2.pkl') else: dataframe2 = pd.read_pickle('sentiment_dataframe.pkl') claims = dataframe2['claim'] word_tokens = [] for c in claims: tokens = informative_words_list(c) word_tokens.append(tokens) dataframe2['word_tokens'] = word_tokens pd.to_pickle(dataframe2, 'embeddings_df2.pkl') print(dataframe2) # Start bot conversation... print('BOT: As a bot I am a terrible debater and always agree') exit_words = ['bye', 'fuckoff', 'quit', 'exit', 'cya', 'goodbye'] while (True): user_input = input() user_input = user_input.lower() if user_input in exit_words: print('BOT: Good talk') break else: print('BOT: ' + counter_argument(user_input, dataframe2))
def main(): check_folders() # Check if database with claims and counterarguments and bert embeddings already been created, otherwise create. if os.path.isfile('Pickles/Trolley.pkl'): dataframe = pd.read_pickle('Pickles/trolley.pkl') else: create_dataframe() dataframe = pd.read_pickle('Pickles/trolley.pkl') # Start bot conversation... print('BOT: As a bot I am a terrible debater and always agree') exit_words = ['bye', 'fuckoff', 'quit', 'exit', 'cya', 'goodbye'] while True: user_input = input() user_input = user_input.lower() if user_input in exit_words: print('BOT: Good talk') break else: response = counter_argument(user_input, dataframe) print('BOT: ' + response[1] + '\n' + response[0])
def run(self) -> None: response = bot_response.counter_argument(self.message, self.dataframe2, self.tb)[0] self.queue.put(response)