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

Text Analysis using Java Collections Framework There is some debate on influence

ID: 3834090 • Letter: T

Question

Text Analysis using Java Collections Framework


There is some debate on influence of Jane Austen on Charlotte Bronte work as a writer (and in generalon all three Bronte sisters’). If you are interested in finding more, feel free to google for their works andthe 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 butnot used by Jane Austen.
To simply this exercise, we will only use the following books:

Jane Austen

Charlotte Bronte

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

Jane Eyre: An Autobiography
(http://www.gutenberg.org/cache/epub/1260/pg1260.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)

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

Mansfield Park
(http://www.gutenberg.org/files/141/141-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.To receive full credit, submit the following:- Java source code file(s)- Nicely formatted report containing a table of top 10 words found in Charlotte Bronte’s books and not
in Jane Austen’s and their counts, and a summary of your insights from this exercise including how this type of analysis can be useful and any suggestions for improvements.

Explanation / Answer

Find the below code for the above problem statement

**********

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/files/1342/1342-pdf.pdf?session_id=6095d4ea3a0487b80283d50574482bb33c2a8be1");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}

***************************

JAN EYRE:

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/cache/epub/1260/pg1260.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

*******************************

Emma

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/files/158/158-0.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

********************

Villette

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/cache/epub/9182/pg9182.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

******************

Sense and sensibillity:

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/cache/epub/161/pg161.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

****************

Shirley

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/files/30486/30486-0.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

**********************

Persuasion:

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/cache/epub/105/pg105.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

************************

The Professor

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/files/1028/1028-0.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

****************

Mansfield park

package com.sagar.oracle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CountUniqueWords {

   public static void main(String args[]) throws IOException {

       //File f = new File("C:/547647/word.txt");
       URL url = new URL("http://www.gutenberg.org/files/141/141-0.txt");
       Scanner in = new Scanner(url.openStream());
       ArrayList arr=new ArrayList();
       HashMap<String, Integer> listOfWords = new HashMap<String, Integer>();
       //Scanner in = new Scanner(f);
       int i=0;
       while(in.hasNext())
       {
           String s=in.next();
           //System.out.println(s);
           arr.add(s);
       }
       Iterator itr=arr.iterator();
       while(itr.hasNext())
       {


           listOfWords.put((String) itr.next(), i);
           System.out.println(listOfWords);
       }

       Set<Object> uniqueValues = new HashSet<Object>(listOfWords.values());

       System.out.println("The number of unique words: "+uniqueValues.size());

   }
}//

***************

P.S kindly note that i have replaced the respective the URL in each of the program and rest of the code is same for all the cases.

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