我正在寻找比较两个对象列表;知道语料库的语言。引用列表由txt构建。语料库也一样。
列出参考/列表语料库
public Canagram(string anagram, int frequency,int percentage)
{
anagram = Anagram; // exemple "a"
frequency = Frequency; // how many "a" in the txt
percentage = Percentage; // what's the percentage compared to the other anagram
}
目标是将每个列表中的每个anagram与百分比相匹配,并返回这两个列表之间的全局百分比匹配。
public static int percentage(List<Canagram> reference, List<Canagram> corpus)
{
//don"t know how to compare this two list properly and return % match
return (int) percentage of match;
}
谢谢!
答案 0 :(得分:0)
不确定这是你想要的,但可能会尝试类似:
int cnt = reference.Count;
int matches = 0;
foreach (var phrase in reference)
{
if (corpus.Contains(phrase))
matches++
}
double percent = (double)matches / (double)cnt;
您可能需要修改类型以便它可以使用标准包含,或者您必须编写自定义MyContains以便您可以确定。
我没有编写上述内容,请原谅错别字,但我相信你应该得到这个小说。