Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pydelicious import DeliciousAPI
- from pydelicious import *
- from getpass import getpass
- from time import sleep
- def invert_dict(d):
- inverse = dict()
- for key in d:
- val = d[key]
- if val not in inverse:
- inverse[val] = [key]
- else:
- inverse[val].append(key)
- return inverse
- def main():
- username = str(raw_input('Username:'))
- pwd = getpass('Pwd:')
- a = DeliciousAPI(username, pwd)
- # Get list of tagged urls
- frogs = get_tagposts('programming')
- sleep(2)
- # Put tagged urls into list
- list1 = []
- for a in range(len(frogs)):
- count = 0
- for b in frogs[a]:
- count += 1
- if count == 4:
- list1.append(frogs[a][b])
- # Get all instances of urls
- dic2 = {}
- for tadpoles in list1:
- spawn = get_urlposts(tadpoles)
- # Put tags into histogram
- for a in range(len(spawn)):
- count = 0
- for b in spawn[a]:
- count += 1
- if count == 3:
- if (spawn[a][b] not in dic2):
- dic2[spawn[a][b]] = 1
- else:
- dic2[spawn[a][b]] = dic2[spawn[a][b]] + 1
- # Invert the histogram and print most often first
- dic3 = invert_dict(dic2)
- # Print results
- res = dic3.keys()
- res.sort()
- res.reverse()
- print res
- for z in res:
- print dic3[z],"appears",z,"times"
- if __name__ == "__main__":
- main()
- """
- Tag similarity. Using the del.icio.us API, create a dataset of tags and items. Use this to calculate similarity between tags and see if you can find any that are almost identical. Find some items that could have been tagged programming but were not.
- Ps Dont know why I used frog related variables
- """
Advertisement
Add Comment
Please, Sign In to add comment