Beispiel #1
0
function word_in_lib($word, $lib)
{
    $metaphone = salMetaphone($word);
    if (isset($lib[$metaphone])) {
        return $lib[$metaphone];
        $possibilities = [];
        foreach ($lib[$metaphone] as $possible) {
            $diff = levenshtein($possible, $word);
            $possibilities[$possible] = $diff;
        }
        uasort($possibilities, "cmp");
        return $possibilities;
    } else {
        if (strlen($word) > 1) {
            $len = strlen($word) - 1;
            $trunc = substr($word, 0, $len);
            return word_in_lib($trunc, $lib);
        } else {
            return [];
        }
    }
}
Beispiel #2
0
<?php

require_once 'words.php';
require_once 'sound_functions.php';
$metaphones = [];
foreach ($words as $word) {
    $metaphone = salMetaphone($word[0]);
    if (!isset($metaphones[$metaphone])) {
        $metaphones[$metaphone] = [];
    }
    $metaphones[$metaphone][] = $word[0];
}
Beispiel #3
0
soundexes for <?php 
echo $word;
?>
:

Library		Output
----------------------
PHP		<?php 
echo soundex($word);
?>

C2.com		<?php 
echo c2SoundEx($word);
?>



metaphones for <?php 
echo $word;
?>
:

Library		Output
----------------------
PHP		<?php 
echo metaphone($word);
?>

Andrew		<?php 
echo salMetaphone($word);