Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(JAVA) Problem 1 and 2: WordFrequencyCounter Knowing how often a word appears in a sentence or block of text is helpful for creating word clouds

(JAVA) Problem 1 and 2: WordFrequencyCounter

Knowing how often a word appears in a sentence or block of text is helpful for creating word clouds and other types of word analysis. And it's more useful when running it against lots of text.

Implement a class WordFrequencyCounter that reads in a file and counts the frequency of words in the file. Then construct a frequency graph (histogram) displaying the words and the frequency, using asterisks to represent each occurrence of the word.

Use this template: WordFrequencyCounter.javaDownload WordFrequencyCounter.java

You must catch any FileNotFoundException that is thrown and print out a message in the format: "File: [filename] not found", e.g., File: words.txt not found

Example:

WordFrequencyCounter counter1 = new WordFrequencyCounter("res/words1.txt"); counter1.getFrequencyGraph(); // the above returns: robert: ****** java: *** fun: ** is: ** agrees: * so: * that: * WordFrequencyCounter.java: /** * Counts the frequencies of words in a file and generates a frequency graph */ public class WordFrequencyCounter { // ADD YOUR INSTANCE VARIABLES HERE /** * Constructor * * @param fileName name of file from which to count word frequencies */ public WordFrequencyCounter(String fileName) { // FILL IN } /** * Returns a word frequency graph based on the input file. Words are sorted * based on frequency (more frequent words appear first) and then by name * (lexicographically). * * Convert all words into lower case for the analysis and graph generation. * * @return a word frequency graph based on the input file */ public String getFrequencyGraph() { return ""; // FIX ME } }

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions