This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Analazing a Paragraph Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Analazing a Paragraph" Watch "Analazing a Paragraph" New topic
Author

Analazing a Paragraph

Peter Burke
Greenhorn

Joined: Sep 28, 2004
Posts: 4
How would I go about pulling in a bunch of text and the as my output having all the words in alphabetical order and listed in occurance, and at the end having it print out the total number of unique words in the text. I know i need to do something with implementing a concrete class of the Map interface. But I need some help on how I would go about doing this.....Thanks!
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
How would I go about pulling in a bunch of text

You could use the StringTokenizer class to get individual words (assuming you have all your text in a String).

print out the total number of unique words in the text

To get unique words, you need to use an implementation of the Set interface. Maps too can be used as they have a Set of unique keys.

output having all the words in alphabetical order and listed in occurance

For sorting you could use TreeSet or TreeMap (implementations of the SortedSet and SortedMap interfaces).

I did not understand what you meant by "listed in occurance", so I cannot tell you whether to use a Set or Map.

Sheldon Fernandes
 
wood burning stoves
 
subject: Analazing a Paragraph
 
Similar Threads
Use of JFileChooser
Working with multiple Languages
Reading lines from file and display?
Extracting drawString() text from JPanel
Extracting drawstring() text from a JPanel