def confusion(message, speaker, public, mdict): if random.random() < markovchance: things = nltk.sent_tokenize(message) words = nltk.word_tokenize(things[-1].lower()) words = english.fixTokenizedText(words) print 'making a response using markov' reply = mdict.answer(words) if reply == '$NULL$': reply = random.choice(acknowledgements) return reply return random.choice(acknowledgements)
def addFromLine(dictionary, rawline): line = [english.br] + english.fixTokenizedText(nltk.word_tokenize(rawline)) + [english.br] addFromTokens(dictionary, line)