-3

我正在寻找比较两个对象列表;了解语料库的语言。参考列表由 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
    }

目标是将每个列表上的每个字谜与百分比匹配,并返回这两个列表之间的全局百分比匹配。

    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;
    }

谢谢!

4

1 回答 1

0

不确定这是您想要的,但也许可以尝试以下方法:

int cnt = reference.Count;
int matches = 0;
foreach (var phrase in reference)
{
if (corpus.Contains(phrase))
    matches++
}
double percent = (double)matches / (double)cnt;

您可能需要修改类型以便它可以与标准 Contains 一起使用,或者您必须编写自定义 MyContains 以便您可以确定。

我没有编译以上内容,所以请原谅拼写错误,但我相信你应该明白这一点。

于 2015-10-01T19:09:18.537 回答