C#字符串"相似"对比测试

mik*_*ike 5 c# string testing

是否有任何库可以轻松比较C#中2个字符串的"相似性"?我在想的是如果你有弦乐,

"This is a test" // 100%
"THIS IS A TEST" // 95%
"    This is a test" // 98%
"This is" // 60%
"Foobar" // 0%
"this test is a" // 70%
Run Code Online (Sandbox Code Playgroud)

与基本字符串相比,每个人都会获得一个分数.

Pie*_*kel 4

看看莱文斯坦。

编辑距离是两个字符串之间的差异。我在网络爬虫应用程序中使用它来比较网页的新旧版本。如果变化足够大,我会在数据库中更新它。

CodeProject 在http://www.codeproject.com/KB/recipes/Levenshtein.aspx上有一个实现。