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 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
import CW7b._
|
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 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
assert(process_ratings(urban_ratings).length == 48580)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
assert(process_movies(urban_movies).length == 9742)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
|