本文整理汇总了Python中pydelicious.get_popular函数的典型用法代码示例。如果您正苦于以下问题:Python get_popular函数的具体用法?Python get_popular怎么用?Python get_popular使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_popular函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_tag_matrix
def build_tag_matrix(tags):
"""
Given a list of bookmarks returns a matrix with
tags as columns and urls as rows.
Returns: tags, urls, matrix
"""
bookmarks = []
for tag in tags:
marks = get_popular(tag=tag)
for bookmark in marks:
url = bookmark["url"]
tags = bookmark["tags"]
bookmarks.append({"url": url, "tags": tags})
tag_list = set(tag for tag in bookmark["tags"] for bookmark in bookmarks)
url_list = []
matrix = []
for bookmark in bookmarks:
row = []
for tag in tag_list:
row.append(1 if tag in bookmark["tags"] else 0)
url_list.append(bookmark["url"])
matrix.append(row)
return tag_list, url_list, matrix
示例2: initializeUserDict
def initializeUserDict(tag, count = 5):
usr_dict = {}
for most_popular in get_popular(tag = tag)[0 : count]:
for person in get_urlposts(most_popular['href']):
usr = person['user']
usr_dict[usr] = {}
return usr_dict
示例3: initializeUserDict
def initializeUserDict(tag,count=5):
user_dict = {}
all_items = {}
# get the top count' popular posts
for p1 in get_popular(tag=tag)[0:count]:
# find all users who posted this
for p2 in get_urlposts(p1['href']):
user = p2['user']
user_dict.setdefault(user,{})
# get user posts
for i in range(3):
try:
posts = get_userposts(user)
break
except:
print "Failed user "+user+", retrying"
time.sleep(4)
for post in posts:
url = post['href']
user_dict[user][url] = 1.0
all_items[url] = 1
#fill in missing items with 0
[ratings.setdefault(item,0.0) for item in all_items for ratings in user_dict.values()]
return user_dict
示例4: initialize
def initialize(tag,count=5):
user_dict = {}
for p1 in get_popular(tag=tag)[0:count]:
for p2 in get_urlposts(p1['url']):
user = p2['user']
user_dict[user] = {}
return user_dict
示例5: initializeUserDict
def initializeUserDict(tag, count=5):
user_dict = {}
for p1 in get_popular(tag=tag)[0:count]:
for p2 in get_urlposts(p1["url"]):
user = p2["user"]
user_dict[user] = {}
return user_dict
示例6: initializeUserDict
def initializeUserDict(tag ,count = 5):
user_dict = {}
#get the top count popular posts
for p1 in get_popular(tag = tag)[0:count]:
for p2 in get_urlposts(p1['url']):
user = p2['user']
user_dict[user] = {}
return user_dict
示例7: initializeUserDict
def initializeUserDict(tag, count=5):
user_dict={}
# 获取前count个最受欢迎的张
for p1 in get_popular(tag = tag)[0:count]:
for p2 in get_urlposts(p1['href']):
user=p2['user']
user_dict[user] = {}
return user_dict
示例8: initlizeUserDict
def initlizeUserDict(tag, count = 5):
user_dict = {}
#获取所有用户都提交过的链接
for p1 in get_popular(tag=tag)[0:count]:
for p2 in get_urlposts(p1['href']):
user = p2['user']
user_dict[user]={}
return user_dict
示例9: initialize_user_dict
def initialize_user_dict(tag,count=5):
user_dict={}
# Get the top "count" popular posts
for p1 in pydelicious.get_popular(tag=tag)[0:count]:
# Find all users who posted the same post url
for p2 in pydelicious.get_urlposts(p1['url']):
user=p2['user']
user_dict[user]={}
return user_dict
示例10: initialize_user_dict
def initialize_user_dict(tag, count=5):
user_dict = {}
# Get the top count popular post
for p1 in get_popular(tag=tag)[0:count]:
# Find all users who posted this
for p2 in get_urlposts(p1['url']):
user=p2['user']
user_dict[user] = {}
return user_dict
示例11: initializeUserDict
def initializeUserDict(tag,count=5):
user_dict={}
# count개의 인기 게시물을 얻음
for p1 in get_popular(tag=tag)[0:count]:
# 이 게시물을 올린 모든 사용자를 얻음
for p2 in get_urlposts(p1['href']):
user=p2['user']
user_dict[user]={}
return user_dict
示例12: initializeUserDict
def initializeUserDict(tag,count = 5):
user_dict = {}
#获取前count个最受欢迎的链接张贴记录
for p1 in get_popular(tag=tag)[0:count]:
#查找所有张贴记录的用户
for p2 in get_urlposts(p1['url']):
user = p2['user']
user_dict[user] = {} #得到一个包含用户的空字典
return user_dict
示例13: initializeUserDict
def initializeUserDict(tag,count=2):
user_dict={}
# get the top count' popular posts
for p1 in get_popular(tag=tag)[0:count]:
# find all users who posted this
for p2 in get_urlposts(p1['href']):
user=p2['user']
user_dict[user]={}
return user_dict
示例14: initializeUserDict
def initializeUserDict(tag, count=5):
user_dict={}
# отримати рахунок найпопулярніших лінків
for p1 in get_popular(tag=tag)[0:count]:
# знайти всіх користувачів, які зберегли цей лінк
for p2 in get_urlposts(p1['href']):
user=p2['user']
user_dict[user]={}
return user_dict
示例15: initializeUserDict
def initializeUserDict(tag, count = 5):
user_dict = {}
# read in top "count" popular posts
for p1 in get_popular(tag = tag)[0:count]:
#find all users who posted this
for p2 in get_urlposts(p1['url']):
user = p2['user']
user_dict[user] = {}
return user_dict