【发布时间】:2012-12-15 13:30:40
【问题描述】:
我想计算 10 000 个文本的 Jaccard 相似度。 Jaccard 相似度很容易计算:相交的长度除以并集的长度。
string sTtxt1 = "some text one";
string sTtxt2 = "some text two";
string sTtxt3 = "some text three";
HashSet<string[]> hashText= new HashSet<string[]>();
hashText.Add(sTtxt1);
hashText.Add(sTtxt2);
hashText.Add(sTtxt3);
double[,] dSimilarityValue;
for (int i = 0; i < hashText.Count; i++)
{
dSimilarityValue[i, i] = 100.00;
for (int j = i + 1; j < dSimilarityValue.Count; j++)
{
dSimilarityValue[i, j] = (double) hashText.ElementAt(i).Intersect(hashText.ElementAt(j)).Count() / (double) hashText.ElementAt(i).Union(hashText.ElementAt(j)).Count();
}
}
对于 .NET4,我应该使用哪些规则来并行化?
谢谢!
【问题讨论】:
标签: c# .net multithreading parallel-processing