main_marking2/danube_test2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 09 Nov 2022 16:44:16 +0000
changeset 435 fda7c39f3b6a
parent 424 daf561a83ba6
permissions -rw-r--r--
updated wordle testing
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
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 389
diff changeset
     5
import M2._
389
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
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 389
diff changeset
    15
val urban_res1 = process_ratings(urban_ratings)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 389
diff changeset
    16
val urban_rat_elems = List(("1","1"), ("1","3"), ("1","6"), ("1","47"))
389
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 389
diff changeset
    18
assert(urban_res1.length == 48580)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 389
diff changeset
    19
assert(urban_rat_elems.forall(urban_res1.contains(_)))
389
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
assert(process_movies(urban_movies).length == 9742)
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
4113d4d8cf62 updated marking 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23