solutions2/danube.scala
author Christian Urban <urbanc@in.tum.de>
Wed, 05 Feb 2020 12:24:27 +0000
changeset 332 e43ad5714b72
parent 325 26058bf089ae
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
fc20e5f83f0e updated
Christian Urban <urbanc@in.tum.de>
parents: 209
diff changeset
     1
// Core Part about Movie Recommendations 
209
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
// at Danube.co.uk
284
fc20e5f83f0e updated
Christian Urban <urbanc@in.tum.de>
parents: 209
diff changeset
     3
//========================================
209
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
325
26058bf089ae updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
     5
26058bf089ae updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
     6
object CW7b { // for purposes of generating a jar
26058bf089ae updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
     7
209
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
import io.Source
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
import scala.util._
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
// (1) Implement the function get_csv_url which takes an url-string
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
//     as argument and requests the corresponding file. The two urls
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
//     of interest are ratings_url and movies_url, which correspond 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
//     to CSV-files.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
//     The function should return the CSV file appropriately broken
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
//     up into lines, and the first line should be dropped (that is without
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
//     the header of the CSV file). The result is a list of strings (lines
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
//     in the file).
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
def get_csv_url(url: String) : List[String] = {
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  val csv = Source.fromURL(url)("ISO-8859-1")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  csv.mkString.split("\n").toList.drop(1)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
}
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
val ratings_url = """https://nms.kcl.ac.uk/christian.urban/ratings.csv"""
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
val movies_url = """https://nms.kcl.ac.uk/christian.urban/movies.csv"""
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
// test cases
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
//val ratings = get_csv_url(ratings_url)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
//val movies = get_csv_url(movies_url)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
//ratings.length  // 87313
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
//movies.length   // 9742
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
// (2) Implement two functions that process the CSV files. The ratings
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
//     function filters out all ratings below 4 and returns a list of 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
//     (userID, movieID) pairs. The movies function just returns a list 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
//     of (movieId, title) pairs.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
def process_ratings(lines: List[String]) : List[(String, String)] = {
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  for (cols <- lines.map(_.split(",").toList); 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
       if (cols(2).toFloat >= 4)) yield (cols(0), cols(1))  
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
}
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
def process_movies(lines: List[String]) : List[(String, String)] = {
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  for (cols <- lines.map(_.split(",").toList)) yield (cols(0), cols(1))  
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
}
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
// test cases
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
//val good_ratings = process_ratings(ratings)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
//val movie_names = process_movies(movies)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
//good_ratings.length   //48580
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
//movie_names.length    // 9742
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
//==============================================
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
// Do not change anything below, unless you want 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
// to submit the file for the advanced part 3!
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
//==============================================
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
// (3) Implement a grouping function that calulates a map
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
//     containing the userIds and all the corresponding recommendations 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
//     (list of movieIds). This  should be implemented in a tail
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
//     recursive fashion, using a map m as accumulator. This map
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
//     is set to Map() at the beginning of the claculation.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
def groupById(ratings: List[(String, String)], 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
              m: Map[String, List[String]]) : Map[String, List[String]] = ratings match {
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  case Nil => m
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  case (id, mov) :: rest => {
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
    val old_ratings = m.getOrElse (id, Nil)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
    val new_ratings = m + (id -> (mov :: old_ratings))
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
    groupById(rest, new_ratings)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  }
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
}
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
// test cases
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
//val ratings_map = groupById(good_ratings, Map())
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
//val movies_map = movie_names.toMap
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
//ratings_map.get("414").get.map(movies_map.get(_)) // most prolific recommender with 1227 positive ratings
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
//ratings_map.get("474").get.map(movies_map.get(_)) // second-most prolific recommender with 787 positive ratings
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
//ratings_map.get("214").get.map(movies_map.get(_)) // least prolific recommender with only 1 positive rating
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
//(4) Implement a function that takes a ratings map and a movie_name as argument.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
// The function calculates all suggestions containing
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
// the movie mov in its recommendations. It returns a list of all these
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
// recommendations (each of them is a list and needs to have mov deleted, 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
// otherwise it might happen we recommend the same movie).
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
def favourites(m: Map[String, List[String]], mov: String) : List[List[String]] = 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
  (for (id <- m.keys.toList;
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
        if m(id).contains(mov)) yield m(id).filter(_ != mov))
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
// test cases
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
// movie ID "912" -> Casablanca (1942)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
//          "858" -> Godfather
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
//          "260" -> Star Wars: Episode IV - A New Hope (1977)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
//favourites(ratings_map, "912").length  // => 80
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
// That means there are 80 users that recommend the movie with ID 912.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
// Of these 80  users, 55 gave a good rating to movie 858 and
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
// 52 a good rating to movies 260, 318, 593.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
// (5) Implement a suggestions function which takes a rating
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
// map and a movie_name as arguments. It calculates all the recommended
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
// movies sorted according to the most frequently suggested movie(s) first.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
def suggestions(recs: Map[String, List[String]], 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
                    mov_name: String) : List[String] = {
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
  val favs = favourites(recs, mov_name).flatten
284
fc20e5f83f0e updated
Christian Urban <urbanc@in.tum.de>
parents: 209
diff changeset
   122
  val favs_counted = favs.groupBy(identity).view.mapValues(_.size).toList
209
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  val favs_sorted = favs_counted.sortBy(_._2).reverse
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  favs_sorted.map(_._1)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
}
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
// test cases
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
//suggestions(ratings_map, "912")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
//suggestions(ratings_map, "912").length  
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
// => 4110 suggestions with List(858, 260, 318, 593, ...)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
//    being the most frequently suggested movies
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
// (6) Implement recommendations functions which generates at most
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
// *two* of the most frequently suggested movies. It Returns the 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
// actual movie names, not the movieIDs.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
def recommendations(recs: Map[String, List[String]],
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
                   movs: Map[String, String],
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
                   mov_name: String) : List[String] =
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
  suggestions(recs, mov_name).take(2).map(movs.get(_).get)                 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
// testcases
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
// recommendations(ratings_map, movies_map, "912")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
//   => List(Godfather, Star Wars: Episode IV - A NewHope (1977))
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
//recommendations(ratings_map, movies_map, "260")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
//   => List(Star Wars: Episode V - The Empire Strikes Back (1980), 
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
//           Star Wars: Episode VI - Return of the Jedi (1983))
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
// recommendations(ratings_map, movies_map, "2")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
//   => List(Lion King, Jurassic Park (1993))
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
// recommendations(ratings_map, movies_map, "0")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
//   => Nil
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
// recommendations(ratings_map, movies_map, "1")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
//   => List(Shawshank Redemption, Forrest Gump (1994))
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
// recommendations(ratings_map, movies_map, "4")
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
//   => Nil  (there are three ratings fro this movie in ratings.csv but they are not positive)     
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
// If you want to calculate the recomendations for all movies.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
// Will take a few seconds calculation time.
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
//val all = for (name <- movie_names.map(_._1)) yield {
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
//  recommendations(ratings_map, movies_map, name)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
//}
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
// helper functions
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
//List().take(2
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
//List(1).take(2)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
//List(1,2).take(2)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
//List(1,2,3).take(2)
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
402a5fe4abb7 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
}