Jump to content

need help with similar_text()


oracle259

Recommended Posts

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

I tried

[code]

$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";
}

[/code]

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

Please help
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.