389
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
import io.Source
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
import scala.util._
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
|
424
|
5 |
import M2._
|
389
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
def urban_get_csv_file(name: String) : List[String] = {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
val csv = Source.fromFile(name)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
csv.mkString.split("\n").toList.drop(1)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
val urban_ratings = urban_get_csv_file("ratings.csv")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
val urban_movies = urban_get_csv_file("movies.csv")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
|
424
|
15 |
val urban_res1 = process_ratings(urban_ratings)
|
|
16 |
val urban_rat_elems = List(("1","1"), ("1","3"), ("1","6"), ("1","47"))
|
389
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
|
424
|
18 |
assert(urban_res1.length == 48580)
|
|
19 |
assert(urban_rat_elems.forall(urban_res1.contains(_)))
|
389
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
assert(process_movies(urban_movies).length == 9742)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
|