Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There is some debate on influence of Jane Austen on Charlotte Bronte work as a w

ID: 3858205 • Letter: T

Question

There is some debate on influence of Jane Austen on Charlotte Bronte work as a writer (and in general on all three Bronte sisters’). If you are interested in finding more, feel free to google for their works and the debate.

For this exercise, using the publicly available books on Project Gutenberg (http://www.gutenberg.org), you are asked to find the top 10 words and number of times they occur in books by Charlotte Bronte but not used by Jane Austen.

To simply this exercise, we will only use the following books:

-Jane Austen:

Pride and Prejudice (http://www.gutenberg.org/files/1342/1342-0.txt)

Emma (http://www.gutenberg.org/files/158/158-0.txt) Villette (http://www.gutenberg.org/cache/epub/9182/pg9182.txt)

Sense and Sensibility (http://www.gutenberg.org/cache/epub/161/pg161.txt) Shirley (http://www.gutenberg.org/files/30486/30486-0.txt)

Persuasion (http://www.gutenberg.org/cache/epub/105/pg105.txt)

Mansfield Park (http://www.gutenberg.org/files/141/141-0.txt)

-Charlotte Bronte:

Jane Eyre: An Autobiography (http://www.gutenberg.org/cache/epub/1260/pg1260.txt)

The Professor (http://www.gutenberg.org/files/1028/1028-0.txt)

Villette (http://www.gutenberg.org/cache/epub/9182/pg9182.txt)

Shirley (http://www.gutenberg.org/files/30486/30486-0.txt)

HashMap (or HashTree) Java Collection will come handy for finding and keeping the count of words. You are only allowed to use Java Collections as described in Chapter 11 of our class textbook. Hint: refer to Word Count Map case study in Chapter 11.

I have read the other people answer but non of them are correct. Please read the question carefully and answer corresponsely.

This is the code in chapter 11 in the book:

1 // Uses maps to implement a word count, so that the user
2 // can see which words occur the most in the book Moby-Dick.
3
4 import java.io.*;
5 import java.util.*;
6
7 public class WordCount {
8 // minimum number of occurrences needed to be printed

9 public static final int OCCURRENCES = 2000;
10
11 public static void main(String[] args)
12 throws FileNotFoundException {
13 System.out.println("This program displays the most");
14 System.out.println("frequently occurring words from");
15 System.out.println("the book Moby Dick.");
16 System.out.println();
17
18 // read the book into a map
19 Scanner in = new Scanner(new File("mobydick.txt"));
20 Map<String, Integer> wordCountMap = getCountMap(in);
21
22 for (String word: wordCountMap.keySet()) {
23 int count = wordCountMap.get(word);
24 if (count > OCCURRENCES) {
25 System.out.println(word + " occurs " +
26 count + " times.");
27 }
28 }
29 }
30
31 // Reads book text and returns a map from words to counts.
32 public static Map<String, Integer> getCountMap(Scanner in) {
33 Map<String, Integer> wordCountMap =
34 new TreeMap<String, Integer>();
35
36 while (in.hasNext()) {
37 String word = in.next().toLowerCase();
38 if (wordCountMap.containsKey(word)) {
39 // seen this word before; increment count
40 int count = wordCountMap.get(word);
41 wordCountMap.put(word, count + 1);
42 } else {
43 // never seen this word before
44 wordCountMap.put(word, 1);
45 }
46 }
47
48 return wordCountMap;
49 }
50 }

Explanation / Answer

The program to count the words from a file using the HashTable map technique is as below. I tried to make it as simple as I would.Hope you'll like it.

WC.java

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Map;
import java.util.StringTokenizer;

public class WC {
static final Integer COUNT = new Integer(1);

public static void main(String args[]) throws IOException {
Hashtable mapping = new Hashtable();
FileReader file = new FileReader("c:/words.txt");
BufferedReader buff = new BufferedReader(file);
String ln;
while ((ln = buff.readLine()) != null) {
lineProc(ln, mapping);
}
Enumeration enu = mapping.keys();
while (enu.hasMoreElements()) {
String keyzzz = (String) enu.nextElement();
System.out.println(keyzzz + " : " + mapping.get(keyzzz));
}
}

static void lineProc(String ln, Map mapping) {
StringTokenizer str = new StringTokenizer(ln);
while (str.hasMoreTokens()) {
countWord(mapping, str.nextToken());
}
}

static void countWord(Map mapping, String wrd) {
Object mkl = mapping.get(wrd);
if (mkl == null) {
mapping.put(wrd, COUNT);
} else {
int uu = ((Integer) mkl).intValue() + 1;
mapping.put(wrd, new Integer(uu));
}
}
}

Please rate the answer if it helped......Thankyou

Hope it helps......

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote