• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pydelicious.get_userposts函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pydelicious.get_userposts函数的典型用法代码示例。如果您正苦于以下问题:Python get_userposts函数的具体用法?Python get_userposts怎么用?Python get_userposts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_userposts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: fill_items

def fill_items(user_dict):
    """
    사용자 정보를 채운다.
    사용자의 포스트 정보를 채운다.
    포스트를 본 적(?)이 있다면 1.0이 될 것이다.

    @type user_dict: dict
    @param user_dict: 사용자 정보

    :return 모든 정보
    """
    all_items = {}

    for user in user_dict:
        for i in range(3):
            try:
                posts = get_userposts(user)
                break
            except Exception, e:
                print e
                print "failed user " + user + ", tetrying"
                time.sleep(4)

        for post in posts:
            url = str(post['url'])
            user_dict[user][url] = 1.0
            # 모든 아이템을 수집한다.
            all_items[url] = 1
开发者ID:otwm,项目名称:CollectiveIntelligence,代码行数:28,代码来源:deliciousrec.py


示例2: fillItems

def fillItems(user_dict):
    all_items={}
    for user in user_dict:
        for i in range(3):
            try:
                print user
                posts=get_userposts(user)
                print len(posts)
                break
            except:
                print "Failed user "+user+", retying"
                time.sleep(4)
        for post in posts:
            url = post['url']
            print url
            user_dict[user][url]=1.0
            all_items[url]=1
    
    print user_dict

# VERY IMPORTANT 
# Recommendations don't need all items to be compared since it just need
# item's name
# But! to find similarity based on it is there or not , 1 or 0,
# it has to have every item_name to be compared!
# Otherwise, it is going to get similarity based on the items that they
# have mutually. <-- VERY IMPORTANT
    for ratings in user_dict.values():
        for item in all_items:
            if item not in ratings:
                ratings[item]=0.0
开发者ID:fkkcloud,项目名称:CollectiveIntelligence,代码行数:31,代码来源:deliciousrec.py


示例3: _fill_items

    def _fill_items(self):
        all_items = {}

        for user in self._usr_dict:
            posts = []

            for i in range(3):
                try:
                    posts = pydelicious.get_userposts(user)
                    break
                except:
                    print "User " + user + " error, trying again."
                    time.sleep(4)

            for post in posts:
                url = post['url']
                self._usr_dict[user][url] = 1.0
                all_items[url] = 1

        for ratings in self._usr_dict.values():
            for item in all_items:
                if item not in ratings:
                    all_items[item] = 0.0
                    ratings[item] = 0.0

        if __debug__: print(all_items)
        self._all_items = all_items
开发者ID:markob,项目名称:dataproc,代码行数:27,代码来源:delicious.py


示例4: fill_items

def fill_items(user_dict):
    """Queries del.icio.us and grabs all a user's links. Modifies the provided
    dictionary and fills it out with the links retrieved from the request.

    Args:
        user_dict: A dictionary with usernames as keys and empty dicts.
    """
    all_items = {}
    # Find links posted by all users.
    for user in user_dict:
        for _ in range(3):
            try:
                posts = pydelicious.get_userposts(user)
                break
            except:
                print "Failed user " + user + ", retrying."
                time.sleep(4)
        for post in posts:
            url = post['url']
            user_dict[user][url] = 1.0
            all_items[url] = 1

        # Fill in the missing items with 0.
        for ratings in user_dict.values():
            for item in all_items:
                if item not in ratings:
                    ratings[item] = 0.0
开发者ID:benedictchen,项目名称:collective-intelligence,代码行数:27,代码来源:deliciousrec.py


示例5: fillItems

def fillItems(userDict):
    """Populate user dict with 1 or 0 based on if link is shared or not.

    :param userDict:
        Most popular users by top posts, dict.
    """
    allItems = {}
    #find links posted by all users
    for user in userDict:
        for i in range(3):
            try:
                posts = get_userposts(user)
                break
            except:
                print "Fallito user "+user+", riprovo."
                time.sleep(4)
        try:
            for post in posts:
                url = post['url']
                userDict[user][url] = 1.0
                allItems[url] = 1
        except Exception as e:
            print user + " has no posts"
    for ratings in userDict.values():
        for item in allItems:
            if item not in ratings:
                ratings[item] = 0.0
开发者ID:andrea-f,项目名称:Python-Collective-Intelligence-Examples,代码行数:27,代码来源:deliciousrec.py


示例6: fillItems

def fillItems(user_dict):
    all_items = {}
    # find links posted by all users
    for user in user_dict:
        print "user: %s" % user
        posts = []
        for i in range(3):
            try:
                posts = get_userposts(user)
                break
            except:
                print "failed user %s, retrying" % user
                time.sleep(4)

        # print "posts: ", posts
        if posts:
            for post in posts:
                url = post['url']
                user_dict[user][url] = 1.0
                all_items[url] = 1

    for ratings in user_dict.values():
        for item in all_items:
            if item not in ratings:
                ratings[item] = 0.0
开发者ID:adamw523,项目名称:collective_intelligence,代码行数:25,代码来源:deliciousrec.py


示例7: getTags

def getTags():
    user_dict = initializeUserDict('curious')
    all_items = {}
    tags_dict = {}
    #find links saved by all users
    for user in user_dict:
	for i in range(3):
	    try:
		posts = get_userposts(user)
		break
	    except:
		print u'Error for user '+user+u', trying one more time'
		time.sleep(4)
	for post in posts:
	    url = post['url']
	    tag = post['tags']
	    tags_dict.setdefault(tag,{})
	    tags_dict[tag][url] = 1.0
	    all_items[url] = 1

    #instead of empty elements write 0
    for ratings in tags_dict.values():
	for item in all_items:
	    if item not in ratings:
		ratings[item] = 0.0
    return tags_dict
开发者ID:tygernach,项目名称:recommendations,代码行数:26,代码来源:deliciousrec.py


示例8: fillItems

def fillItems(user_dict):

    all_items = {}
    for user in user_dict:
        if user == '':
            continue
        else:
            print "Processing ",user

        for i in range(3):
            try:
                posts = get_userposts(user)
                break
            except:
                print "Failed for %s, retrying.." % user
                time.sleep(4)
        for post in posts:
            url = post['url']
            print url
            user_dict[user][url] = 1.0
            all_items[url] = 1
    
    for ratings in user_dict.values():
        for item in all_items:
            if item not in ratings:
                ratings[item] = 0.0
开发者ID:abhijat,项目名称:ProgrammingCollectiveIntelligence,代码行数:26,代码来源:deliciousrec.py


示例9: fillItems

def fillItems(user_dict):
    all_items={}
    for user in user_dict:
        for i in range(3):
            try:
                # get_userposts()는 주어진 사용자에 대한 모든 게시글을 리턴
                posts=get_userposts(user)
                break
            except:
                print "Failed user "+user+", retrying"
                time.sleep(4)
                
        for post in posts:
            url=post['url']
            user_dict[user][url]=1.0
            all_items[url]=1
            # user_dict = {'유저이름', {'url 주소' : 평가점수1 or 0}}  will be returned
            # all_items = { 'url주소' : 1}
            
    #참조 list(d.items()) == list(zip(d.keys(), d.values()))
    # user_dict.values()는 '유저이름'을 를 가리킴
    for ratings in user_dict.values():
        for item in all_items:
            if item not in ratings:
                ratings[item]=0.0
开发者ID:koreaccm,项目名称:algorithm,代码行数:25,代码来源:deliciousrec.py


示例10: fillItems

	def fillItems(user_dict):
		all_items={}
		# Find links posted by all users
		for user in user_dict:
			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['url']
			#print user_dict[user]
			user_dict[user]=1.0
			all_items[url]=1
		# Fill in missing items with 0
		#print (type(set(user_dict.values())),type(set(all_items.values())))
		#print json.dumps(user_dict,indent=1)
		#print json.dumps(all_items,indent=1)
		not_in=set.difference(set(user_dict.keys()),set(all_items.keys()))
		#logging.info(not_in)
		# for ratings in user_dict.values( ):
		# 	for item in all_items:
		# 		if item not in ratings:
		# 			ratings[item]=0.0
		#print not_in
		for item in not_in:
			user_dict[item]=0.0
		return user_dict
开发者ID:wandeg,项目名称:AI,代码行数:30,代码来源:Workers.py


示例11: 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
开发者ID:adgaudio,项目名称:kaggle-wordpress,代码行数:26,代码来源:deliciousrec.py


示例12: fill_items

def fill_items(user_dict):
    """
    Returns: a dict whose keys are users and values are 
    dicts of link: rating pairs, where 1 stands for having 
    posted the link, else 0.
    """
    all_items = {}
    for user in user_dict:
        for _ in range(3):
            try:
                posts = get_userposts(user)
                break
            except:
                print("Failed user " + user + ", retrying")
                sleep(4)
        for post in posts:
            url = post['url']
            user_dict[user][url] = 1.0
            all_items[url] = 1

    for ratings in user_dict.values():
        for item in all_items:
            if item not in ratings:
                ratings[item] = 0.0

    return all_items
开发者ID:tim-millar,项目名称:recommendations,代码行数:26,代码来源:deliciousrec.py


示例13: fillItems

def fillItems(user_dict):
    all_items = []

    # find links posted by all users
    for user in user_dict:
        posts = None

        for i in range(3):
            try:
                posts = get_userposts(user)
                break
            except:
                print "Failed user "+user+", retrying"
                time.sleep(4)

        if posts is not None:
            for postInfo in posts:
                url = postInfo['url']
                user_dict[user][url] = 1.0
                all_items.append(url)

    for item in all_items:
        for ratings in user_dict.values():
            if item not in ratings:
                ratings[item] = 0.0
开发者ID:ArtanisCV,项目名称:Mercury,代码行数:25,代码来源:delicious.py


示例14: fillItems

def fillItems(user_dict):
  all_items={}
  # Find links posted by all users
  
  count = 0
  len_ud = len(user_dict)
  for user in user_dict:
    count += 1
    print "Processing user %d of %d" % (count, len_ud)
    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['url']
      user_dict[user][url]=1.0
      all_items[url]=1
  
  # Fill in missing items with 0
  for ratings in user_dict.values():
    for item in all_items:
      if item not in ratings:
        ratings[item]=0.0
开发者ID:funwalla,项目名称:Sandbox,代码行数:27,代码来源:deliciousrec.py


示例15: get_ratings_for

def get_ratings_for(users):
    user_ratings = {}
    all_items = set([])

    for user in users:
        user_ratings[user] = {}
        for i in range(3):
            try:
                posts = get_userposts(user)
                break
            except:
                print "Failed user "+user+", retrying in 4 seconds"
                time.sleep(4)
        for post in posts:
            url = post['url']
            user_ratings[user][url] = 1.0
            all_items.add(url)

    # Fill in missing items with 0
    # TODO: Don't think we should do this.
    for ratings in user_ratings.values():
        for item in all_items:
            if item not in ratings:
                # Note: this relies on dictionary mutability
                ratings[item] = 0.0

    return user_ratings
开发者ID:duncanmortimer,项目名称:Working-Through-PCI,代码行数:27,代码来源:deliciousrec.py


示例16: get_userpost_details

def get_userpost_details(user, num_retries = 3, sleep_time=10):
    for i in range(num_retries):
        try:
            posts = get_userposts(user)
            break
        except:
            print "Exception caught while retrying for user ", user, " retry number ", i
            sleep(sleep_time)
            
    return posts
开发者ID:amolnayak311,项目名称:Programming-Collective-Intelligence,代码行数:10,代码来源:deliciousrec.py


示例17: fillAll

def fillAll(user_dict):
  # Find links posted by all users
  for user in user_dict:
    for i in range(3):
      try:
        print 'getting userposts for', user
        posts = get_userposts(user)
        break
      except:
        print 'Failed user %s, retrying' % user
        time.sleep(4)
    user_dict[user] = posts
开发者ID:Ignorant-Instigator,项目名称:collectiveintelligence-book,代码行数:12,代码来源:deliciousrec.py


示例18: fillItems

def fillItems(user_dict):
    all_items={}
    # Find links posted by all users
    for user in user_dict:
        if user is None or user=='': continue
        for post in get_userposts(user):
            url=post['url']
            user_dict[user][url]=1.0
            all_items[url]=1
    # Fill in missing items with 0
    for ratings in user_dict.values():
        for item in all_items:
            if item not in ratings:
                ratings[item]=0.0

    return user_dict
开发者ID:akostrikov,项目名称:py-tests,代码行数:16,代码来源:deliciousrec.py


示例19: fillItems

def fillItems(user_dict):
	all_items = {}
	for user in user_dict:
		for i in range(3):
			try:
				posts = get_userposts(user)
				break
			except Exception:
				print 'Failed user', user, ", retrying"
		for post in posts:
			url = post['href']
			user_dict[user][url] = 1.0
			all_items[url] = 1
	for ratings in user_dict.values():
		for item in all_items:
			if item not in ratings:
				ratings[item] = 0.0
开发者ID:Aaron-Cai,项目名称:Programming-Collective-Intelligence,代码行数:17,代码来源:deliciousrec.py


示例20: fillItems

def fillItems(user_dict):
    all_items = {}
    for user in user_dict:
        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
    for ratings in user_dict.values():
        for item in all_items:
            if item not in ratings:
                ratings[item] = 0.0
开发者ID:wenyuanma,项目名称:littlePython,代码行数:18,代码来源:delicious.py



注:本文中的pydelicious.get_userposts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python signature.is_signature_compatible函数代码示例发布时间:2022-05-25
下一篇:
Python pydelicious.get_urlposts函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap