marking2/danube_test2.scala
author Christian Urban <urbanc@in.tum.de>
Tue, 29 Oct 2019 09:54:52 +0000
changeset 278 0c2481cd8b1c
parent 227 b5f3e814a710
child 284 9a04eb6a2291
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
227
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
import io.Source
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
import scala.util._
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
def urban_get_csv_file(name: String) : List[String] = {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
  val csv = Source.fromFile(name)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
  csv.mkString.split("\n").toList.drop(1)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
val urban_ratings = urban_get_csv_file("ratings.csv")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
val urban_movies = urban_get_csv_file("movies.csv")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
assert(process_ratings(urban_ratings).length == 48580)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
assert(process_movies(urban_movies).length == 9742)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18