上記のコードを機能させることができましたが、次のエラーが発生します。グーグルを試してみたところ、データ型の問題であることが少しわかりました。しかし、上記の 2 つの関数のデータ型を変更すると、同じエラーが発生します。私は何をすべきか?
*この場合、字句密度指数を計算しようとしています。
//For counting unique words
private void UniqueWordCount(string fbStatus)
{
int count = 0;
var countedWordList = new List<string>(100);
var reg = new Regex(@"\w+");
foreach (Match match in reg.Matches(fbStatus))
{
string word = match.Value.ToLower();
if (!countedWordList.Contains(word))
{
++count;
countedWordList.Add(word);
}
}
label_totaluniquewords.Text = count.ToString();
}
//For counting total words
private void SplitWords(string fbStatus)
{
int splitWords = fbStatus.Split(new char[] { ' ' },StringSplitOptions.RemoveEmptyEntries).Count();
label_totalwordcount.Text = splitWords.ToString();
}
//For counting lexical density (trying to make this work...)
private void CalculateLexicalDensity(string fbStatus)
{
int ld = 0;
ld = (UniqueWordCount(fbStatus) / SplitWords(fbStatus)) * 100;
label_lexicaldensity.Text = ld.ToString();
}