7 \begin{document} |
7 \begin{document} |
8 |
8 |
9 |
9 |
10 %% should ask to lower case the words. |
10 %% should ask to lower case the words. |
11 |
11 |
12 \section*{Main Part 2 (Scala, 7 Marks)} |
12 \section*{Main Part 2 (Scala, 6 Marks)} |
13 |
13 |
14 |
14 |
15 \noindent |
15 \noindent |
16 You are asked to implement a Scala program for recommending movies |
16 You are asked to implement a Scala program for recommending movies |
17 according to a ratings list. This part is due on \cwSEVENa{} at 5pm.\bigskip |
17 according to a ratings list. This part is due on \cwSEVENa{} at 5pm.\bigskip |
37 implementations in form of \texttt{jar}-files. This allows you to run |
37 implementations in form of \texttt{jar}-files. This allows you to run |
38 any test cases on your own computer. For example you can call Scala on |
38 any test cases on your own computer. For example you can call Scala on |
39 the command line with the option \texttt{-cp danube.jar} and then |
39 the command line with the option \texttt{-cp danube.jar} and then |
40 query any function from the template file. Say you want to find out |
40 query any function from the template file. Say you want to find out |
41 what the function \texttt{} produces: for this you just need |
41 what the function \texttt{} produces: for this you just need |
42 to prefix it with the object name \texttt{CW7b}. If you want to find out what |
42 to prefix it with the object name \texttt{M2}. If you want to find out what |
43 these functions produce for the list \texttt{List("a", "b", "b")}, |
43 these functions produce for the list \texttt{List("a", "b", "b")}, |
44 you would type something like: |
44 you would type something like: |
45 |
45 |
46 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
46 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
47 $ scala -cp danube.jar |
47 $ scala -cp danube.jar |
48 scala> val ratings_url = |
48 scala> val ratings_url = |
49 | """https://nms.kcl.ac.uk/christian.urban/ratings.csv""" |
49 | """https://nms.kcl.ac.uk/christian.urban/ratings.csv""" |
50 |
50 |
51 scala> CW7b.get_csv_url(ratings_url) |
51 scala> M2.get_csv_url(ratings_url) |
52 val res0: List[String] = List(1,1,4 ...) |
52 val res0: List[String] = List(1,1,4 ...) |
53 \end{lstlisting}%$ |
53 \end{lstlisting}%$ |
54 |
54 |
55 \subsection*{Hints} |
55 \subsection*{Hints} |
56 |
56 |
68 |
68 |
69 |
69 |
70 \newpage |
70 \newpage |
71 |
71 |
72 |
72 |
73 \subsection*{Main Part 2 (7 Marks, file danube.scala)} |
73 \subsection*{Main Part 2 (6 Marks, file danube.scala)} |
74 |
74 |
75 You are creating Danube.co.uk which you hope will be the next big thing |
75 You are creating Danube.co.uk which you hope will be the next big thing |
76 in online movie renting. You know that you can save money by |
76 in online movie renting. You know that you can save money by |
77 anticipating what movies people will rent; you will pass these savings |
77 anticipating what movies people will rent; you will pass these savings |
78 on to your users by offering a discount if they rent movies that |
78 on to your users by offering a discount if they rent movies that |
187 of two most-suggested movies (as calculated above). But it returns |
187 of two most-suggested movies (as calculated above). But it returns |
188 the actual movie name, not the movieID. If fewer movies are recommended, |
188 the actual movie name, not the movieID. If fewer movies are recommended, |
189 then return fewer than two movie names.\\ |
189 then return fewer than two movie names.\\ |
190 \mbox{}\hfill [1 Mark] |
190 \mbox{}\hfill [1 Mark] |
191 |
191 |
192 \item[(7)] Calculate the recommendations for all movies according to |
192 %\item[(7)] Calculate the recommendations for all movies according to |
193 what the recommendations function in (6) produces (this |
193 % what the recommendations function in (6) produces (this |
194 can take a few seconds). Put all recommendations into a list |
194 % can take a few seconds). Put all recommendations into a list |
195 (of strings) and count how often the strings occur in |
195 % (of strings) and count how often the strings occur in |
196 this list. This produces a list of string-int pairs, |
196 % this list. This produces a list of string-int pairs, |
197 where the first component is the movie name and the second |
197 % where the first component is the movie name and the second |
198 is the number of how many times the movie was recommended. |
198 % is the number of how many times the movie was recommended. |
199 Sort all the pairs according to the number |
199 % Sort all the pairs according to the number |
200 of times they were recommended (most recommended movie name |
200 % of times they were recommended (most recommended movie name |
201 first).\\ |
201 % first).\\ |
202 \mbox{}\hfill [1 Mark] |
202 % \mbox{}\hfill [1 Mark] |
203 |
203 |
204 \end{itemize} |
204 \end{itemize} |
205 |
205 |
206 \end{document} |
206 \end{document} |
207 |
207 |