private static Map<Integer, List<Integer>> getUserLikes() { List<Rating> ratings = DB.getRatings(); Map<Integer, List<Rating>> userPartitionnedRatings = DataOperation.groupByUser(ratings); Map<Integer, List<Integer>> userLikedMovies = new HashMap<Integer, List<Integer>>(); for (Entry<Integer, List<Rating>> entry : userPartitionnedRatings.entrySet()) { Integer userId = entry.getKey(); userLikedMovies.put(userId, new ArrayList<Integer>()); for (Rating r : entry.getValue()) { if (r.rating() > DB.likeThreshold()) { userLikedMovies.get(userId).add(r.movie()); } } } return userLikedMovies; }
private static List<Integer> getMovieIds() { Map<Object, Movie> movies = DB.getMovies(); List<Integer> movieIds = new ArrayList<Integer>(); for (Entry<Object, Movie> entry : movies.entrySet()) { movieIds.add((Integer) entry.getKey()); } return movieIds; }