如何比较两个文本文件并获得匹配百分比 [英] How to compare two text files and get the match percentage

查看:147
本文介绍了如何比较两个文本文件并获得匹配百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何比较两个文本文件的内容并获得匹配百分比.

我比较了两个字符串,并能够获得总百分比匹配.
例如:

How to compare the contents of two text files and get the match percentage.

I compared two strings and was able to get the total percentage match.
ex:

string s1 = Manju is good guy;
string s2 = Manju is good guy;


百分比是100%
我使用的代码是.


The percentage is 100%
The code I have used is.

protected void Button1_Click(object sender, EventArgs e)
      {
          int count = 0;
          string[] str1 = TextBox1.Text.Split(' ');
          string[] str2 = TextBox2.Text.Split(' ');
          for (int i = 0; i < str1.Length; i++)
          {
              for (int j = 0; j <str2.length;>              {
                  if (str1[i] == str2[j])
                  { 
                      count++;
                  }
              }
          }
           double per=0.0;
           if (count <= str1.Length)
               per = (count * 100) / str1.Length;
           else
               per = 100;
          Response.Write(per.ToString());


但是问题是,当我提供以下数据时.


But the problem is, when I give the following data.

string s1 = Manju is good guy;
string s2 = Manju is bad guy;


百分比是75%

含义完全不同,但匹配率为80%
有什么算法或代码可以比较单词和含义,或类似的东西.
请帮帮我.

提前谢谢.

更新:
我的错.我说80%是因为,我的话是满举是个好人.因此,发布问题时出错. Heh.


The percentage is 75%

The meaning is totally different, but the matching is of 80%
Is there any algorithm or codes where in I can compare the word and also the meaning or something like that.
Please help me out.

Thanks in advance.

Update:
My bad. I said 80% because, my string was Manju is a good guy. So, the mistake while posting the problem. Heh.

推荐答案

如果您能够对一个系统进行编程,该系统能够可靠地提取单词和短语的语义(含义)(现在不留句子)从给定语言的句子中选择并使其具有可比性,我保证您会成为一个非常受人钦佩和非常有钱的人.

(当您有效地表示高于75 == 80时,我看不到您将如何到达那里)

干杯!

-MRB
If you are able to program a system that will be able to reliably extract the semantic (meaning) of words and phrases (leave alone sentences for now) from a sentence in a given language and make them comparable too, I''ll promise you will be a greatly admired and very rich man.

(I can''t really see how you would get there though when you are effectively stating above that 75 == 80)

Cheers!

-MRB


四个词中有一个是不同的,因此匹配率为75%.您如何到达80?

如果要考虑含义,这绝非易事.那你怎么匹配句子呢?以下两个句子的百分比应为:

One out of four words is different so match is 75%. How do you arrive at 80?

It is not at all going to be easy if you want to take meanings to into account. And how would you match the sentences then? What should be the percentage for the following two sentences:

Manju is good guy
Manju is better guy



您将必须使用字典并根据英语语法定义每个可能的匹配百分比.这真是艰巨的工作.一切顺利,如果您实现了这一点,请告诉我们. :)



You will have to use a dictionary and define every possible match percentage based upon English grammar. This really tough job. All the best and if you implement this, let us know. :)


不!自然人语音的语义分析和语义比较远高于现代技术水平.您可能只会发现一些具有高度实验性的作品,但我怀疑它们是否能有效地做到这一点.

如果您不相信,请尝试进行任何计算机翻译.它会证明它有多远.

要么忘记它,要么全力以赴.

—SA
No! Analysis of the semantics and comparison of semantics of natural human speech is well above the level of the modern technology. You may only find some highly experimental works, but I doubt they effectively do that.

If you don''t believe it, try to do any computer translation; it will demonstrate it how far it is.

Either forget it or dedicate your whole life to it.

—SA


这篇关于如何比较两个文本文件并获得匹配百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆