本文整理匯總了Python中recommender.Recommender.generate方法的典型用法代碼示例。如果您正苦於以下問題:Python Recommender.generate方法的具體用法?Python Recommender.generate怎麽用?Python Recommender.generate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recommender.Recommender
的用法示例。
在下文中一共展示了Recommender.generate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: authentication
# 需要導入模塊: from recommender import Recommender [as 別名]
# 或者: from recommender.Recommender import generate [as 別名]
def authentication(ckey, csecret, atoken, atokensecret):
consumer_key = ckey
consumer_secret = csecret
access_token = atoken
access_token_secret = atokensecret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
my_tweets = api.user_timeline()
my_first_tweet = my_tweets[0].text
following = api.friends()
#d = defaultdict(list)
dict_of_followed_tweets = {}
for friend in following:
follow_acc = api.get_user(friend.screen_name)
dict_of_followed_tweets[friend.screen_name] = friend.timeline()
#x = [method for method in dir(friend) if callable(getattr(friend, method))]
#return template('My fi {{dict_of_followed_tweets}}', dict_of_followed_tweets=dict_of_followed_tweets)
recommenderObj = Recommender()
generatedTweet = recommenderObj.generate(my_tweets, 1, following, 2, dict_of_followed_tweets)
return template('Result: {{generatedTweetHere}}',generatedTweetHere =generatedTweet)