Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python 2.7 Question The dictionary should be created by reading the file link ad

ID: 666133 • Letter: P

Question

Python 2.7 Question

The dictionary should be created by reading the file link added. How can I add this data in codes below.

https://drive.google.com/folderview?id=0Bz_aB61VIRZAfnNoamZmZVdVR19TNmdmVDBwbk5aN1JsNkQyNTVRLUgwVVB2elVIUHBfcFE&usp=sharing

# Dictionary that contains tag and url
dict_mint = {}

# Insert into dict_mint
def insert_dict_mint(tag,url):
   if tag in dict_mint:
       dict_mint[tag].append(url);
   else:
       dict_mint[tag] = [url]

# Dictionary that contains URL as key and another Dictionary as value
dict_url = {}

def insert_dict_url(url,tag):
   if url in dict_url:
       l = dict_mint[tag]
       count = 0;
       for urls in l:
           if (url == urls):
               count += 1;
       value = dict_url[url]
       value[tag] = count
   else:
       l = dict_mint[tag]
       count = 0;
       for urls in l:
           if (url == urls):
               count += 1;
       dict_temp = {}
       dict_temp[tag] = count
       dict[url] = dict_temp

PROBLEM DESCRIPTION delicious (formerly, del.icio.us) is a web site that allows users to save their favorite links (bookmarks) online. Each link has also one or more "tag"'s that represent the categories or topics of the website, such as "programming", "cooking", "research", etc. In this assignment, you will do the following: 1. Using the provided dataset (described below), first create a dictionary of tags and items (i.e., web links). That is, you will create a dictionary which will be very similar to critics dictionary where the key will be a URL, and value will be another dictionary in which key will be a tag and value will be how many times that URL is tagged with that tag 2. Calculate similarity between tags, and see if you can find any tags that are almost identical (i.e. similarity is almost 1). For instance, find some items that could have been tagged "programming" but were not. 3. Compute top-5 item-based and user-based tag recommendations for five URLs that you choose. DATASET This dataset consists of 100,000 popular URLs bookmarked on Delicious within a past time window Each URL includes the date first saved, the number of saves, and the top 10 tags used and their respective counts. The dataset is available on LMS under /Assignments/Assignment 1, file name: Webscope _R5.tgz DATA FORMAT The file is tab delimited; the columns are (from left to right): » URL » Number of saves . Date of first save

Explanation / Answer

Below are the code in python to read file data from url

import urllib
txt = urllib.urlopen(target_https://drive.google.com/folderview?id=0Bz_aB61VIRZAfnNoamZmZVdVR19TNmdmVDBwbk5aN1JsNkQyNTVRLUgwVVB2elVIUHBfcFE&usp=sharing).read()