Search the web
Sign In
New User? Sign Up
StrongTypes · Free .NET Generics Help
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
About a function that counts word frequency from a file   Message List  
Reply | Forward Message #44 of 44 | Next >
hi all,

I was working on function that counts the word frequency of file,
what i want to do is find the word that occurs the most, so I am not
familiar with generic collections,so i need your help to get this
right ? dict<string, int > ---> <word, occurence>

the alogrithm that I came up is to assume that the first word in the
dictionary to be the most frequent so far and as we go along if we
find a word occurence greater than the one we started with then we
use that as greatest so far and once we get to the end then return
the word that occurs the most and how many times it has been counted.
am i on the right track

public void FindMostFreqWord()
{
largestSofar = word_counter[0];
foreach (KeyValuePair<string, int> kvp in word_counter)
{
if (kvp.Value > largestSofar)
{
largestSofar = kvp.Value;
string word = kvp.Key;
}
}
Console.WriteLine("the most frequent word is " + word_counter);

}

thanks in advance





Tue Sep 4, 2007 4:46 pm

a_abdi406
Offline Offline
Send Email Send Email

Forward
Message #44 of 44 | Next >
Expand Messages Author Sort by Date

hi all, I was working on function that counts the word frequency of file, what i want to do is find the word that occurs the most, so I am not familiar with...
a_abdi406
Offline Send Email
Sep 15, 2007
3:17 pm
< Prev Topic  |  Next Topic >
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help