本文整理匯總了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()