Skip to content
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
1 change: 1 addition & 0 deletions src/main/java/BookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public List<String> getText(File file) throws FileNotFoundException {
return words;
}


public List<String> topWords(List<String> words, int amount) {
return words.stream().distinct()
.sorted(Comparator.comparingInt(word -> Collections.frequency(words, word)).reversed())
Expand Down
1 change: 0 additions & 1 deletion src/main/java/BookStatistic.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public BookStatistic(List<String> topWords, int uniqWords) {
this.topWords = topWords;
this.uniqWords = uniqWords;
}

@Override
public String toString() {
return "BookStatistic{" +
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public static void main(String[] args) throws IOException {
BookStatSerialize bookStatSerialize = new BookStatSerialize();
System.out.println("Press any key or enter exit for EXIT");



while (!scanner.next().equals(exitCmd)) {
System.out.println("Please enter the book");
File book = new File(PATH + scanner.next());
Expand All @@ -25,14 +23,10 @@ public static void main(String[] args) throws IOException {
int uniqWords = bookParser.uniqWords(words);
BookStatistic bookStatistic = new BookStatistic(topWords, uniqWords);
System.out.println(bookStatistic);
bookStatSerialize.serialize(bookStatistic, new File(PATH + "statistic_of_"+ book.getName()));
System.out.println("Press " + exitCmd + " to exit");
bookStatSerialize.serialize(bookStatistic, new File(PATH + "statistic_of_" + book.getName()));

System.out.println("Press " + exitCmd + " to exit");
}

scanner.close();


}

}