I have a database field which contains string
values.
I am looking a way to find top 10 maximum occured words from the field
First get all the words from that field:
IEnumerable<string> allWords = from entry in table
from word in entry.Field.Split(' ')
select word;
Then group them by their counts:
IEnumerable<string> result = from word in allWords
group word by word into grouped
let count = grouped.Count()
orderby count descending
select grouped.Key;
Get top 10 results:
result.Take(10);
var result =
Regex.Matches(s, @"\b\w+\b").OfType<Match>()
.GroupBy(k => k.Value, (g, u) => new { Word = g, Count = u.Count() })
.OrderBy(n => n.Count)
.Take(10);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With