equal
deleted
inserted
replaced
1 // Core Part about Movie Recommendations |
1 // Main Part 2 about Movie Recommendations |
2 // at Danube.co.uk |
2 // at Danube.co.uk |
3 //=========================================== |
3 //=========================================== |
4 |
4 |
5 object CW7b { |
5 object M2 { |
6 |
6 |
7 import io.Source |
7 import io.Source |
8 import scala.util._ |
8 import scala.util._ |
9 |
9 |
10 // (1) Implement the function get_csv_url which takes an url-string |
10 // (1) Implement the function get_csv_url which takes an url-string |
156 // recommendations(ratings_map, movies_map, "4") |
156 // recommendations(ratings_map, movies_map, "4") |
157 // => Nil (there are three ratings for this movie in ratings.csv but they are not positive) |
157 // => Nil (there are three ratings for this movie in ratings.csv but they are not positive) |
158 |
158 |
159 |
159 |
160 |
160 |
161 // (7) Calculate the recommendations for all movies according to |
|
162 // what the recommendations function in (6) produces (this |
|
163 // can take a few seconds). Put all recommendations into a list |
|
164 // (of strings) and count how often the strings occur in |
|
165 // this list. This produces a list of string-int pairs, |
|
166 // where the first component is the movie name and the second |
|
167 // is the number of how many times the movie was recommended. |
|
168 // Sort all the pairs according to the number |
|
169 // of times they were recommended (most recommended movie name |
|
170 // first). |
|
171 |
|
172 def most_recommended(recs: Map[String, List[String]], |
|
173 movs: Map[String, String]) : List[(String, Int)] = ??? |
|
174 |
|
175 |
|
176 // testcase |
|
177 // |
|
178 //most_recommended(ratings_map, movies_map).take(3) |
|
179 // => |
|
180 // List((Matrix,698), |
|
181 // (Star Wars: Episode IV - A New Hope (1977),402), |
|
182 // (Jerry Maguire (1996),382)) |
|
183 |
|
184 |
|
185 |
|
186 } |
161 } |