main_testing2/danube_test2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 03 Nov 2022 09:55:11 +0000
changeset 431 ef68136b9a96
parent 422 217bbd700594
permissions -rw-r--r--
updated jars
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
422
217bbd700594 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 403
diff changeset
    15
val urban_res1 = process_ratings(urban_ratings)
217bbd700594 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 403
diff changeset
    16
val urban_rat_elems = List(("1","1"), ("1","3"), ("1","6"), ("1","47"))
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
422
217bbd700594 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 403
diff changeset
    18
assert(urban_res1.length == 48580)
217bbd700594 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 403
diff changeset
    19
assert(urban_rat_elems.forall(urban_res1.contains(_)))
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
assert(process_movies(urban_movies).length == 9742)