# -*- coding: utf-8 -*- """ Created on Wed Jan 30 14:17:06 2019 chatbot corpus comes from: https://github.com/gunthercox/chatterbot-corpus @author: whq672437089 """ import generateResponse as gr import preprocess as pp content = "" with open("corpus.txt") as infile: for line in infile: content = content + " " + line.lower() qrDict = pp.generateConversationTurnDict(content) index = 0 for question, answer in qrDict.items(): print("question is:" + question + ', answer is' + answer + ', index is:' + str(index)) index += 1 pureQuestions = pp.pureQuestionsText(qrDict) sentenceTokens = pp.generateSentenceTokens(pureQuestions) index2 = 0 for question in sentenceTokens: print("index is:" + str(index2) + ", question is:" + question) index2 += 1 ql = [] for question, response in qrDict.items(): ql.append(question)
def testGenerateConversationTurnDict(self): self.assertTrue( self.template == pp.generateConversationTurnDict(self.content))