Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submitting WordCloud #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
4 changes: 3 additions & 1 deletion src/WordCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Long>::getValue).reversed())
.sorted(Comparator.comparing(Entry<String, Long>::getValue).reversed().thenComparing(Comparator.comparing(Entry<String, Long>::getKey)))
// keep only the top ones
.limit(numWordsToKeep)
// convert frequencies into groups (Entry is immutable, so create a new one)
Expand Down Expand Up @@ -119,6 +119,8 @@ private static List<String> readWords (Scanner input,
Predicate<String> select) {
List<String> 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;
Expand Down