main_marking2/danube_test2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 08 Nov 2021 02:16:33 +0000
changeset 409 0e55b6313adc
parent 389 4113d4d8cf62
child 424 daf561a83ba6
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
389
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
import io.Source
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
import scala.util._
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
import CW7b._
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
def urban_get_csv_file(name: String) : List[String] = {
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
  val csv = Source.fromFile(name)
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
  csv.mkString.split("\n").toList.drop(1)
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
}
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
val urban_ratings = urban_get_csv_file("ratings.csv")
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
val urban_movies = urban_get_csv_file("movies.csv")
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
assert(process_ratings(urban_ratings).length == 48580)
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
assert(process_movies(urban_movies).length == 9742)
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20