From d6757a00aff434ee0702061536a147976f67bdd3 Mon Sep 17 00:00:00 2001 From: mohabg Date: Thu, 25 Feb 2016 16:52:16 -0500 Subject: [PATCH] Committing --- .classpath | 6 ++++++ src/WordCloud.java | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .classpath diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/WordCloud.java b/src/WordCloud.java index fab3e35..3850ac8 100644 --- a/src/WordCloud.java +++ b/src/WordCloud.java @@ -86,7 +86,7 @@ private WordCloud topWords (int numWordsToKeep, int groupSize) { myTagWords = myTagWords.stream() // sort from most frequent to least // TODO: add secondary comparison alphabetically based on word - .sorted(Comparator.comparing(Entry::getValue).reversed()) + .sorted(Comparator.comparing(Entry::getValue).reversed().thenComparing(Comparator.comparing(Entry::getKey))) // keep only the top ones .limit(numWordsToKeep) // convert frequencies into groups (Entry is immutable, so create a new one) @@ -119,6 +119,8 @@ private static List readWords (Scanner input, Predicate select) { List contents = Arrays.stream(input.useDelimiter(END_OF_FILE).next().split(WHITESPACE)) // TODO: add map and filter calls using parameters + .filter(select) + .map(xform) .collect(Collectors.toList()); input.close(); return contents;