marking2/danube_test2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 09 Nov 2022 20:51:29 +0000
changeset 440 f3bfc496d6ca
parent 284 9a04eb6a2291
permissions -rw-r--r--
updated jars
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
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
     5
import CW7b._
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
     6
227
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
def urban_get_csv_file(name: String) : List[String] = {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  val csv = Source.fromFile(name)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
  csv.mkString.split("\n").toList.drop(1)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
val urban_ratings = urban_get_csv_file("ratings.csv")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
val urban_movies = urban_get_csv_file("movies.csv")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
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_ratings(urban_ratings).length == 48580)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
assert(process_movies(urban_movies).length == 9742)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20