main_testing2/danube_test2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 08 Nov 2021 01:39:00 +0000
changeset 403 ffce7b61b446
parent 379 5616b45d656f
child 422 217bbd700594
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
import io.Source
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
import scala.util._
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
403
ffce7b61b446 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
     5
import M2._
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 211
diff changeset
     6
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
def urban_get_csv_file(name: String) : List[String] = {
379
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 347
diff changeset
     8
  val csv = Source.fromFile(name)("ISO-8859-1")
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
  csv.mkString.split("\n").toList.drop(1)
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
}
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
val urban_ratings = urban_get_csv_file("ratings.csv")
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
val urban_movies = urban_get_csv_file("movies.csv")
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
assert(process_ratings(urban_ratings).length == 48580)
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
assert(process_movies(urban_movies).length == 9742)
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20