本文整理匯總了Python中markov.Markov.load_db方法的典型用法代碼示例。如果您正苦於以下問題:Python Markov.load_db方法的具體用法?Python Markov.load_db怎麽用?Python Markov.load_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類markov.Markov
的用法示例。
在下文中一共展示了Markov.load_db方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from markov import Markov [as 別名]
# 或者: from markov.Markov import load_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 load_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)