• Post Reply Bookmark Topic Watch Topic
  • New Topic

Analazing a Paragraph  RSS feed

 
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!
 
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
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!