Get the snarf file that has the data files you need for this assignment or get them here.
Below is a list of the files and essential methods you need to create for this assignment. Feel free to also create additional helper methods.
IN ALL OF THESE, PRINT A LOT OF OUTPUT WHILE DEBUGGING. Strongly suggested after you create a new structure, print it out to make sure it was built correctly. If it is large, just print a small part of it, such as the first 20 items in a list, or print just ten items from the dictionary.
Here is the suggested 12-step process to work on this project.
At this point you have completed ReadFood.py, Recommender.py and ReadFood.py. You've completed a large part of this assignment!
You are almost done!
Below are a list of all the files and methods you need to write. More detail for each are on the details page.
processdata( filename)
: The
function must read data about food and raters and return the
information in a list and dictionary. (see
details)filename
argument must be a txt
file of food and ratings like this sample small one (also in the
snarf ) and in this format.
rater
place rating place rating place rating
rater
place rating place rating place rating place rating place rating
rater
place rating place rating
....
The call processdata(filename)
must return two things:
itemlist
a list of items (restaurants) being rated: [
"restaurant
", "restaurant
",
... ]
ratingsdict
a dictionary of raters
and their ratings of the restaurants:
{"ratername" : [integer ratings for each restaurant], "ratername" : [integer ratings for each restaurant], ... }
processdata( booktitles, bookratings )
: The
function must read data about books and raters and return the
information in a list and dictionary. (see
details)
The booktitles
argument must be a txt
file of books (supplied with the snarf or here) with an
author and the corresponding book title on the same line. The format
is line number, followed by "::", followed by author, followed by
"::", followed by title of book:
1::author::bookTitle
2::author::bookTitle
3::author::bookTitle
....
The bookratings
argument must be a txt
file of raters (supplied with the snarf or here) with each
line having the
name of a rater followed by a rating for all the books (with 0 if not
rated) with each rating on a separate line.
ratername
rating
rating
...
rating
ratername
rating
rating
...
rating
ratername
rating
rating
...
rating
....
The call processdata( booktitles, bookratings )
must return two things:
itemlist
a list of books being rated (combine each
author and title into a string "title,author"
[
"title,
author
", "
title,
author
",
... ]
raterdict
a dictionary of raters
and their ratings of the books:
{"ratername" : [integer ratings for each book], "ratername" : [integer ratings for each book], ... }
processdata( movieratings )
The movieratings
argument must be a txt
file of movies (supplied with the snarf or here) in the format
of one movie rating per line with three pieces of information:
rater, rating, and movietitle, in that order, with the parenthesis around each field. Note that movietitles may have blanks in them. (ratername)(title)(rating)
(ratername)(title)(rating)
(ratername)(title)(rating)
Return valuesThe processdata( movieratings )
must return two things:
itemlist
a list of movies being rated: [
"
title
", "
title
",
"
title
", ... ]
(see details and examples here)
ratingsdict
a dictionary of raters and
their ratings of the movies:
{"ratername" : [integer ratings for each movie], "ratername" : [integer ratings for each movie], ... }
Note that all three functions processdata
return the same types: a
list of strings (each item being rated) and a dictionary in which
keys are raters and values are lists of integer ratings by each rater.
In the module Recommender.py
you must write the three
functions shown in the details pages:
averages
, similarities
, and
recommended
. Each of these will be used for comparing
ratings of restaurants, movies and books in other programs, that is,
all three of these will be imported into other Python modules.
Here is briefly what each of these do, with more detail for each on the details page.
This is the main program for restaurant recommendations. It should read in the file of restaurant recommendations and then call processdata in ReadFood.py to get the list of restaurants and the dictionary of raters and their ratings.
Then it will call the functions in Recommender to find out what the average rating is for each restaurant, find top raters who are similar to another rater, and give recommendations to a rater.
In particular, it should produce the following output. For all three make sure your output is easily identifiable and understandable.
foodRatings.txt
averages
).
similarities
).
recommended
).
This is the main program for book recommendations. It should read in the files of book recommendations and then call processdata in ReadBooks.py to get the list of books and authors, and the dictionary of raters and their ratings.
Then it will call the functions in Recommender to find out what the average rating is for each book, find top raters who are similar to another rater, and give recommendations to a rater.
In particular, it should produce the following output. For all three make sure your output is easily identifiable and understandable.
authorsAndBooks.txt
and bookRatings.txt
.
averages
).
similarities
).
recommended
).
This is the main program for movie recommendations. It should read in the file of movie recommendations and then call processdata in ReadMovies.py to get the list of movies and the dictionary of raters and their ratings.
Then it will call the functions in Recommender to find out what the average rating is for each movie, find top raters who are similar to another rater, and give recommendations to a rater.
In particular, it should produce the following output. For all three make sure your output is easily identifiable and understandable.
movieRatings.txt
averages
).
similarities
).
recommended
).