Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Complete the method uniqueWords. Unique words should count the number of unique words in a text. Words that occur more than once should

  1.  

1. Complete the method uniqueWords. Unique words should count the number of unique words in a text. Words that occur more than once should only be counted one time. You will need to clean the data to obtain an accurate count. 2. Hyphenated words should be counted as one word. 3. Case should not matter. For example, "The" and "the" should only be counted once. 4. Numbers and punctuation should not count as words. However, words like its and it's should both be counted. 5. For example, the text for Time Machine should contain approximatly -4,660 unique words. 6. Main.java 7. import java.io.Buffered Reader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.HashSet; import java.util.stream.Collectors; 8. class Main { 9. public static void main(String[] args) throws FileNotFoundException, IOException { String file = "TimeMachine.txt"; List list; try (Buffered Reader br = new Buffered Reader(new FileReader(file))) { list = br.lines().collect(Collectors.toList()); } 10. 11. } 12. public static int uniqueWords(List lines) { 13. return 0; 14. System.out.println("" + file.replace(".txt","")); System.out.println("Unique words: " + uniqueWords(list)); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Programming questions

Question

Discuss the role of OLAP in the context of descriptive analytics.

Answered: 1 week ago

Question

Why must some identifiers be composite rather than simple?

Answered: 1 week ago