私はstring
値を含むデータベースフィールドを持っています。その数によってその後テキストから出現する単語を最大限に見つける方法は?
IEnumerable<string> allWords = from entry in table
from word in entry.Field.Split(' ')
select word;
グループにそれら: 私はトップを見つけるために道を探しています10最大フィールド
私はstring
値を含むデータベースフィールドを持っています。その数によってその後テキストから出現する単語を最大限に見つける方法は?
IEnumerable<string> allWords = from entry in table
from word in entry.Field.Split(' ')
select word;
グループにそれら: 私はトップを見つけるために道を探しています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);
まずそのフィールドからすべての単語を取得から単語を発生し
IEnumerable<string> result = from word in allWords
group word by word into grouped
let count = grouped.Count()
orderby count descending
select grouped.Key;
上位10の結果を得る:
result.Take(10);
最後に 'select'または' group by'がありません。 – leppie
思い出させるためのThx –
ここでは、数字と簡単な例があります:1行に1列、またはテーブル全体で一つの列から
class Program
{
static void Main(string[] args)
{
int[] nums = new int[] { 2, 3, 4, 5, 6, 1, 2, 3, 1, 1, 1, 7, 12, 451, 13,
46, 1, 1, 3, 2, 3, 4, 5, 3, 2, 4, 4, 5, 6, 6, 8, 9, 0};
var numberGroups =
(from n in nums
group n by n into g
orderby g.Count() descending
select new { Number = g.Key, Count = g.Count() }
).Take(10);
Console.ReadLine();
}
}
よろしく
を? –
各フィールドに1つの単語がありますか? –
あなたはどのデータベースを使用していますか? – briantyler