Dictionaries #44
+1
-15
@@ -6,16 +6,15 @@ import requests
|
||||
import asyncio
|
||||
import os
|
||||
import feedparser
|
||||
import json
|
||||
from datetime import datetime
|
||||
import re
|
||||
|
||||
|
||||
class Chatbot(commands.Cog):
|
||||
"""Een heuse chatbot. Under construction..."""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.voice_states = {}
|
||||
self.END_OF_MESSAGE = "<EOM>"
|
||||
self.START_OF_MESSAGE = "<SOM>"
|
||||
self.pmLast = datetime(2018, 1, 1, 1, 1, 1)
|
||||
@@ -89,7 +88,6 @@ class Chatbot(commands.Cog):
|
||||
def __check(self, ctx):
|
||||
return True
|
||||
|
||||
|
||||
#The "Guus filter"
|
||||
#Don't allow to learn from very large personal messages
|
||||
#Only learn from 10 personal messages per hour at most
|
||||
@@ -187,8 +185,6 @@ class Chatbot(commands.Cog):
|
||||
|
||||
return newRespPairDict
|
||||
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=True)
|
||||
async def trainmarkovchat(self, ctx, channelId=409751773595566081, nrOfMessages=50):
|
||||
"""Train that chain, jermaine
|
||||
@@ -201,7 +197,6 @@ class Chatbot(commands.Cog):
|
||||
|
||||
await ctx.channel.send("Ik heb weer wat nieuwe woordjes geleerd. :slight_smile:")
|
||||
|
||||
|
||||
#Learns from an x number of messages from a certain channel
|
||||
async def learnFromMessagesInChannel(self, channel, nrOfMessages):
|
||||
|
||||
@@ -256,7 +251,6 @@ class Chatbot(commands.Cog):
|
||||
|
||||
np.save("markov_dict.npy", wordDict)
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def reageer(self, ctx):
|
||||
"""Laat Stroop ergens op reageren.
|
||||
@@ -329,7 +323,6 @@ class Chatbot(commands.Cog):
|
||||
return self.translateTo("nl", respons)
|
||||
|
||||
def getResponseForMessageLocal(self, wordsToRespondTo):
|
||||
|
||||
MAX_N_WORDS = 100 #Don't use more words than this
|
||||
|
||||
#Get dictionary/Markov chain
|
||||
@@ -372,7 +365,6 @@ class Chatbot(commands.Cog):
|
||||
#Pick a next word:
|
||||
chain.append(self.pickNextWord(pairPossibilities))
|
||||
|
||||
|
||||
if chain[0] == self.START_OF_MESSAGE:
|
||||
chain = chain[1:-1] #remove <SOM> and <EOM>
|
||||
else:
|
||||
@@ -389,9 +381,6 @@ class Chatbot(commands.Cog):
|
||||
#await ctx.channel.send(' '.join(chain))
|
||||
return ' '.join(chain)
|
||||
|
||||
|
||||
|
||||
|
||||
#Try to count the number of syllables in a word
|
||||
#Used to make Haikus
|
||||
def countSyllables(self, word: str):
|
||||
@@ -436,7 +425,6 @@ class Chatbot(commands.Cog):
|
||||
#Make a nice Haiku
|
||||
def getHaiku(self):
|
||||
MAX_N_TRIES = 50
|
||||
|
||||
#Get dictionary/Markov chain
|
||||
wordDict = np.load('markov_dict.npy', allow_pickle=True).item()
|
||||
wordPairDict = wordDict['pairs']
|
||||
@@ -462,7 +450,6 @@ class Chatbot(commands.Cog):
|
||||
async def haiku(self, ctx):
|
||||
"""Stroop is een poëet. Laat hem een Haiku maken.
|
||||
"""
|
||||
|
||||
response = self.getHaiku()
|
||||
await ctx.channel.send(response)
|
||||
|
||||
@@ -673,7 +660,6 @@ class Chatbot(commands.Cog):
|
||||
def get_limerick(self):
|
||||
MAX_ATTEMPTS = 15
|
||||
MAX_LINE_TRIES = 5
|
||||
|
||||
for _ in range(MAX_ATTEMPTS):
|
||||
limerick = []
|
||||
used_rhymes = {}
|
||||
|
||||
Reference in new issue
Block a user