Move the word comparison function to common file
This commit is contained in:
parent
ea95c63e18
commit
98b3498de2
2 changed files with 18 additions and 15 deletions
16
common.php
Normal file
16
common.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
|
||||
function areWordsSimilar(string $word1, string $word2)
|
||||
{
|
||||
$word_sim = similar_text($word1, $word2, $word_perc);
|
||||
$meta_sim = similar_text(metaphone($word1), metaphone($word2), $meta_perc);
|
||||
$sndx_sim = similar_text(soundex_fr($word1), soundex_fr($word2), $sndx_perc);
|
||||
if ($word_perc >= 90 || $meta_perc >= 90 || $sndx_perc >= 90) {
|
||||
return true;
|
||||
}
|
||||
if ($word_perc >= 80 && $meta_perc >= 80 && $sndx_perc >= 80) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue