本文介绍了检查Java中一个字符串听起来像另一个字符串的程度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Java中是否有任何类可以使用自己的标准检查一个String与另一个String相等的数量.示例:

I'd like to know if there is any class in Java able to check, using its own criteria, how much a String is equal to another one.Example :

  • William Shakespeare / William Shakespeare : might be 100%
  • William Shakespe**a**re / William Shakespe**e**re : might have above 90%
  • William Shakespeare / Shakespeare, William : might have above 70% (just examples)
  • William Shakespeare / William Shakespeare : might be 100%
  • William Shakespe**a**re / William Shakespe**e**re : might have above 90%
  • William Shakespeare / Shakespeare, William : might have above 70% (just examples)

推荐答案

通常,有 levenshtein 算法,该算法仅输出为了将一个字符串转换为另一个字符串而必须执行(按字符排列)的插入/更新/删除操作的数量. Apache的 StringUtils 类具有实现.

Generally, there is the levenshtein algorithm, which just outputs how many insert/update/delete operations you would have to perform (characterwise) in order to transform one string into another. Apache's StringUtils class has an implementation.

这篇关于检查Java中一个字符串听起来像另一个字符串的程度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 12:59