I'm trying to obtain the similarity percentage for 2 Strings when using the Levenshtein function but the percentages doesn't seem to match the percentage
returned by similar_text($str1,$str2,$match_percent);
Below is what I use to calculate the similarity percentage
$dist = levenshtein($str1,$str2); $str1len = strlen($str1); $str2len = strlen($str2); if($str1len > $str2len) { $pct = ($str1len - $dist)/$str1len; } else { $pct = ($str2len - $dist)/$str2len; } $pct = $pct*100;
What am I missing from the calculation?
Thanks.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php