嘿,我正在使用Levenshteins算法来获得源和目标字符串之间的距离.
我也有从0到1返回值的方法:
/// <summary>
/// Gets the similarity between two strings.
/// All relation scores are in the [0, 1] range,
/// which means that if the score gets a maximum value (equal to 1)
/// then the two string are absolutely similar
/// </summary>
/// <param name="string1">The string1.</param>
/// <param name="string2">The string2.</param>
/// <returns></returns>
public static float CalculateSimilarity(String s1, String s2)
{
if ((s1 == null) || (s2 == null)) return 0.0f;
float dis = LevenshteinDistance.Compute(s1, s2); …Run Code Online (Sandbox Code Playgroud) 有没有人知道一种简单的方法来比较两个字符串,以产生两者之间的"差异"?(在一个数值)我一直在抓住谷歌运气不好.在做了一些编码后,它并不像我想象的那么简单.有线索吗?