本文整理汇总了Python中markov.Markov.load_brain方法的典型用法代码示例。如果您正苦于以下问题:Python Markov.load_brain方法的具体用法?Python Markov.load_brain怎么用?Python Markov.load_brain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markov.Markov
的用法示例。
在下文中一共展示了Markov.load_brain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from markov import Markov [as 别名]
# 或者: from markov.Markov import load_brain [as 别名]
message_parts = message_body.split("] ")
user = message_parts[0].replace("[",'')
message = message_parts[1]
if command in message:
#chattiness = self.get_augument('chattiness',1)
sentence = markovchain.generate_sentence()
print sentence
values = {'message' :sentence }
data = urllib.urlencode(values)
req = urllib2.Request(webhook_url+"?message="+str(urllib.quote(sentence)))
response = urllib2.urlopen(req)
response.close()
else:
training_file.write(message+"\n")
markovchain.load_brain(message)
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
training_file = open(training_text, 'r+')
print "Loading "+training_text+" into brain."
markovchain.load_brain(training_file)
print 'Brain Reloaded'
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()