あなたが探している主題は、用語頻度分析または単語頻度分析の名前で行きます.次のコードは、各単語の頻度を与えることができます. 特定のフレーズの頻度を見つけることも非常に簡単ですが、ドキュメント全体を分析して、頻度が 1 を超える用語のシーケンスを見つけるのは少し複雑です。
void Analyze(ref String InputText, ref Dictionary<string, int> WordFreq)
{
string []Words = InputText.Split(' ');
for (int i = 0; i < Words.Length; i++)
{
if (WordFreq.ContainsKey(Words[i]) == false)
WordFreq.Add(Words[i], 1);
else
{
WordFreq[Words[i]]++;
}
}
}
void DoWork()
{
string InputText = "free numerology compatibility numerology calculator free free numerology report numerology reading free numerology reading";
Dictionary<string, int> WordFreq = new Dictionary<string,int>();
Analyze(ref InputText,ref WordFreq);
string result = null;
foreach (KeyValuePair<string, int> pair in WordFreq)
{
result += pair.Value + " Instances of " + pair.Key + "\r\n";
}
MessageBox.Show(result);
}
private void Form1_Load(object sender, EventArgs e)
{
DoWork();
}