diff --git a/homeworks/02-goodreads/resources/src/bg/sofia/uni/fmi/mjt/goodreads/recommender/similaritycalculator/descriptions/TFIDFSimilarityCalculator.java b/homeworks/02-goodreads/resources/src/bg/sofia/uni/fmi/mjt/goodreads/recommender/similaritycalculator/descriptions/TFIDFSimilarityCalculator.java index bf35cab4..76e91049 100644 --- a/homeworks/02-goodreads/resources/src/bg/sofia/uni/fmi/mjt/goodreads/recommender/similaritycalculator/descriptions/TFIDFSimilarityCalculator.java +++ b/homeworks/02-goodreads/resources/src/bg/sofia/uni/fmi/mjt/goodreads/recommender/similaritycalculator/descriptions/TFIDFSimilarityCalculator.java @@ -5,6 +5,7 @@ import bg.sofia.uni.fmi.mjt.goodreads.tokenizer.TextTokenizer; import java.util.Collection; +import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -47,7 +48,7 @@ private double dotProduct(Map first, Map second) Set commonKeys = new HashSet<>(first.keySet()); commonKeys.retainAll(second.keySet()); - return keySet.stream() + return commonKeys.stream() .mapToDouble(word -> first.get(word) * second.get(word)) .sum(); } @@ -59,5 +60,4 @@ private double magnitude(Collection input) { return Math.sqrt(squaredMagnitude); } - }