1.Learning Objectives:

1)Use Map data structure to solve problems

2)Use java.util.TreeMap class

3)Use java.util.Scanner class and regular expression to extract tokens from text.

4)Read from file and parse the data

5)Write and test java program

2.General Descriptions:

Write a java program that counts the number of unique words in an input file, ignoring the case and punctuation characters (for example, Map, map, and map. are all map), and print out the words in alphabetic order along with the occurrences of the words.

If wordfile1.txt has the following content:

"Map", "map", and "map." are all "map". Should print out the words in alphabetic order along with the occurrences of the words.

The running output should be:

What is the name of the text file? wordfile1.txt
all=1
along=1
alphabetic=1
and=1
are=1
in=1
map=4
occurrences=1
of=1
order=1
out=1
print=1
should=1
the=3
with=1
words=2

3.Requirements: See the General Descriptions above.

4.References:

1)Koffman & Wolfgang, Data Structures: Abstraction and Design Using Java, 2nd Edition:

  • Pages 662-664: Using java.util.Scanner to read from a file and extract tokens using Scanner.findInLine;
  • Pages 624-626: Regular Expressions;
  • Pages 329-331: Case Study: Writing an Index for a Term Paper (using TreeSet);
  • Pages 370-371: Example 7.4: Writing an Index for a Term Paper (using TreeMap);
  • Pages 400: Example 7.11 (display the entries of the map - one entry per line); and
  • Pages 401-403 Case Study: Implementing a Cell Phone Contact List (using TreeMap)

2)Lecture notes

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.