Reputation: 10463
I need to group words as similar and then find the frequence.
So text like "moron and morons sat on moronic bench with mormons"
will yield result
Moron 3
Sat 1
Mormon 1
I need to be able to push a text or list of exact words in one query and receive generic words with frequency.
From C#, can use SQL Server.
Upvotes: 1
Views: 87
Reputation: 16958
In C# version you can use Regex
with Linq; like this:
var txt = "moron and morons sat on moronic bench with mormons";
var words = Regex.Matches(txt, @"\w+").OfType<Match>().Select(c => c.Value).ToList();
var result = words.Select(c => new {Word = c, Count = words.Count(w => w.Contains(c))})
.OrderByDescending(o=> o.Count).ToList();
[ C# Fiddle Demo ]
Upvotes: 0
Reputation: 175676
You could use sys.dm_fts_index_keywords_by_document:
SELECT *
FROM sys.dm_fts_index_keywords_by_document(DB_ID('db_name'),OBJECT_ID('tab_name'))
Upvotes: 2