两个字符串有多少相似?(90%,100%,40%) [英] How much two strings are similar?(90%,100%,40%)

查看:94
本文介绍了两个字符串有多少相似?(90%,100%,40%)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入字符串和一个字符串集合,我想比较输入字符串并找到最佳选择查看。我想编写一个函数来告诉我这两个字符串有多少相似之处。 ?

I have an input string and a collection of strings and I want to compare the input string and find the best choices to view.I want to write a function that tell me how much this two string are similar.have you any idea?

推荐答案

对于短字符串差异,您要搜索的算法称为:

For 'short' string differences the algorithm you are searching for is called:

Levenshtein距离

http://zh.wikipedia.org/wiki/Levenshtein_distance

如果要查找句子中的差异,您可能希望检查以下算法:解决 最长公共序列的问题。

For seeking differences in sentences you may wish to check for algorithms that solve the 'longest common sequence' problem.

执行此操作的一个工具(最初是Unix)' diff '

One tool that does that is the (originally unix) 'diff'

这篇关于两个字符串有多少相似?(90%,100%,40%)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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