Пример #1
0
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)
Пример #2
0
def addFromLine(dictionary, rawline):
	line =  [english.br] + english.fixTokenizedText(nltk.word_tokenize(rawline)) + [english.br]
	addFromTokens(dictionary, line)