Jump to content


Photo

need help with similar_text()


  • Please log in to reply
No replies to this topic

#1 oracle259

oracle259
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 28 September 2006 - 04:42 AM

How can i combine the similar_text() and levenshtein() functions to get a more accurate match percentage than similar_text()

I tried


$match = similar_text($word1, $word2, $percent);
$percent = round($percent, 1);
 
if ($percent > 5) {

$lev = levenshtein($word1, $word2);
$count1 = strlen($word1);
$count2 = strlen($word2);
$cnt = ($count1/$count2) * $lev;
$cnt = round($cnt, 1);

if ($cnt > 1) {
echo "fail";
} else {
echo "pass";
}
} else {
echo "pass";
}


but it fails to pass ass in asset because $percent = 0 and $cnt = 1.5

Please help




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users