1. Complete the method uniqueWords. Unique words should count the number of unique words in a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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)); } 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)); }
Expert Answer:
Related Book For
Modern Database Management
ISBN: 978-0133544619
12th edition
Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi
Posted Date:
Students also viewed these programming questions
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Research various global financial services organizations (for example, UBS AG, E-Trade, Schwab, ING, Bank of America, HSBC, RBS) through their company websites and other publicly available...
-
Using the Trust Services Principles and Criteria for the Online Privacy Principle, develop an online privacy policy for Alltel Stadium that could be posted on the stadiums website for customers to...
-
Determine the horizontal and vertical components of reaction at pin C and the force in the pawl of the winch in Prob. 510.
-
Burger Office Equipment produces two types of desks: standard and deluxe. Deluxe desks have oak tops and more expensive hardware and require additional time for finishing and polishing. Standard...
-
Home nations (such as U. S., France, Kenya) of runners in a marathon Determine whether the data described are qualitative or quantitative and give their level of measurement. If the data are...
-
TLR produces plastic that is used for injection molding applications such as gears for small motors. In 2010, the first year of operations, TLR produced 6,000 tons of plastic and sold 5,000 tons. In...
-
public class test { public static void main(String args) { } int x, y; x = 4; y = 6; System.out.println(another(x, y)); // Line 1 System.out.println(another2(x)); // Line 2 static int another(int a,...
-
December 31, 2014, trial balances for Pledge Company and its subsidiary Stom Company follow: Pledge Company purchased 72,000 shares of Stom Company's common stock on January 1, 2011, for $300,000. On...
-
Find S 4xsin((x + y) )dA, where R is the region enclosed by y- axis and the two parabolas y = x - x and y = 2 - x by changing u = x + y 2 and v = x.
-
How do the visuals and the text of the Digital World Technologies advertise- ment employees, customers, and stockholders that the company is committed to diversity in the workplace? Also, explain how...
-
Briefly explain the differences between combinational and sequential logic. [2 marks] (b) With the aid of appropriate diagrams, briefly explain the operation of Moore and Mealy finite state machines...
-
You own a stock that had returns of 11.52 percent, 7.74 percent, 24.76 percent, and 16.94 percent over the past four years. What was the geometric average return for this stock?
-
A project has the following cash flows: Year Cash Flow 0 $ 69,500 1 47,000 2 30,400 a. What is the IRR for this project? (Do not round intermediate calculations and enter your answer as a percent...
-
The iceberg of quality costs referenced in the text illustrates both the visible, as well as less visible, costs associated with poor quality. For this discussion, consider the quality costs "below...
-
A lower days sales in inventory for Company X when compared to other companies,indicates that Company X; a)is able to sell its inventory quickly. b)is spending more on inventory storage. c)is holding...
-
Provide an example of an aggressive accounting practice. Why is this practice aggressive?
-
Add a subtype discriminator (named Person Type) to the diagram you created in Problem and Exercise 2-29.
-
Discuss the role of OLAP in the context of descriptive analytics.
-
Why must some identifiers be composite rather than simple?
-
Problem Decide whether the sampling method is independent or dependent. Then determine whether the response variable is qualitative or quantitative. (a) Joliet Junior College decided to implement a...
-
In the Spacelab Life Sciences 2 payload, 14 male rats were sent to space. Upon their return, the red blood cell mass (in milliliters) of the rats was determined. A control group of 14 male rats was...
-
Using the data from Table 2, construct a \(95 \%\) confidence interval estimate of the mean difference, \(\mu_{d}\). By Hand Approach Step 1 Compute the differenced data. Because the sample size is...
Study smarter with the SolutionInn App