本文整理汇总了Python中markov.Markov.make_db方法的典型用法代码示例。如果您正苦于以下问题:Python Markov.make_db方法的具体用法?Python Markov.make_db怎么用?Python Markov.make_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markov.Markov
的用法示例。
在下文中一共展示了Markov.make_db方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from markov import Markov [as 别名]
# 或者: from markov.Markov import make_db [as 别名]
def main(params, tracklist):
# twitter info
consumer_key = params.get('twitter', 'consumer_key')
consumer_secret = params.get('twitter', 'consumer_secret')
access_token = params.get('twitter', 'access_token')
access_token_secret = params.get('twitter', 'access_secret')
# auth & api
auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
# markov
corpus = params.get('markov', 'corpus')
is_pickled = params.getboolean('markov', 'pickled')
m = Markov(corpus)
if is_pickled:
m.load_db()
else:
m.make_db()
# listener
print 'Starting listener for "{}"...'.format(', '.join(tracklist))
listener = Listener(m, is_pickled, api=api)
stream = tweepy.Stream(auth, listener)
stream.filter(track=tracklist)
示例2: main
# 需要导入模块: from markov import Markov [as 别名]
# 或者: from markov.Markov import make_db [as 别名]
def main(params):
consumer_key = params.get('twitter', 'consumer_key')
consumer_secret = params.get('twitter', 'consumer_secret')
access_token = params.get('twitter', 'access_token')
access_token_secret = params.get('twitter', 'access_secret')
auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
corpus = params.get('markov', 'corpus')
is_pickled = params.getboolean('markov', 'pickled')
m = Markov(corpus)
if is_pickled:
m.load_db()
else:
m.make_db()
text = m.gen(climit=140)
api.update_status(text)