• Post Reply Bookmark Topic Watch Topic
  • New Topic

Top Ten Words Count  RSS feed

 
venkatPrasad Regula
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an issue. I need to read a file and display the occurence of top ten words in the file and how many times each word has occured. At the same time there is a list of reserved words, which are not to be counted. So if I come across this reserved word I need to skip. Can someone give me the psudocode I need to follow to acomplish this task.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to give REALLY high level pseudocode since this sounds like a homework assignment (and you'll learn more about reasoning it out.)

Read file storing each word in a Map with the word as key and the value as the count ignoring any reserved words
Print out the keys for the highest 10 counts

Now it's your turn. Try to make these two sentences into some actual pseudocode. It doesn't have to be complete. But post something here and you'll get more tips.
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Jeanne's level of detail.

I'd just add you can also use a Map to store the reserved words.

And sorting a Map by it's values takes a bit of research but it's not bad once you figure it out.

Joe
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Areeda wrote:I'd just add you can also use a Map to store the reserved words.

Why a map? I'd use a Set since we don't need to count reserved words.
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:
Joe Areeda wrote:I'd just add you can also use a Map to store the reserved words.

Why a map? I'd use a Set since we don't need to count reserved words.


You're right,that's even better.
That's what I get for typing before I've made coffee.

Joe
 
venkatPrasad Regula
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just give me some time (half day) I will resolve it and paste the psudocode. The psudocode that has been posted was really helpful. Thanks in advance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!