• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Analazing a Paragraph

 
Peter Burke
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic