Skip to content

Commit

Permalink
Hw2 tf idf class fix (#185)
Browse files Browse the repository at this point in the history
* Align return types between README and /resources in Homework 02 assignment

* Fixes for HW2

---------

Co-authored-by: 100yo <[email protected]>
Co-authored-by: Mihail Zonev <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2024
1 parent fe0bbf0 commit a2c79ef
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -47,7 +48,7 @@ private double dotProduct(Map<String, Double> first, Map<String, Double> second)
Set<String> commonKeys = new HashSet<>(first.keySet());
commonKeys.retainAll(second.keySet());

return keySet.stream()
return commonKeys.stream()
.mapToDouble(word -> first.get(word) * second.get(word))
.sum();
}
Expand All @@ -59,5 +60,4 @@ private double magnitude(Collection<Double> input) {

return Math.sqrt(squaredMagnitude);
}

}

0 comments on commit a2c79ef

Please sign in to comment.