progarmm source code that demonstrate frequency words(use from c# tokenizer)?
Loading
progarmm source code that demonstrate frequency words(use from c# tokenizer)?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Azharunissa KhanPosted Jan 1, 2014, 11:16 PM
VulpesPosted Dec 27, 2013, 10:32 AM
Here's some revised code:
Azharunissa KhanPosted Dec 27, 2013, 1:53 AM
Instead of taking a plain text as input,can we take a text file at run time and execute the code given
above?
If so,what is the procedure or code required?
And thank you so much for providing us the code.
VulpesPosted May 16, 2012, 9:32 AM
using System;
using System.Linq;
using System.Text.RegularExpressions;
class Test
{
static void Main()
{
string text = "The quick brown fox jumps over the quick lazy dog and the quick brown cat";
MatchCollection mc = Regex.Matches(text, @"\b\w+\b");
var query = from Match m in mc group m by m.Value.ToLower() into g select new {Word = g.Key, Frequency = g.Count()};
foreach(var item in query)
{
Console.WriteLine("{0} : {1}", item.Word, item.Frequency);
}
Console.ReadKey();
}
}
A 'word' for this purpose can only consist of the characters: a-z, A-Z, 0-9 or underscore but can be easily changed to include other characters.
The output of the above program should be:
the : 3
quick : 3
brown : 2
fox : 1
jumps : 1
over : 1
lazy : 1
dog : 1
and : 1
cat : 1