<?php
require_once 'class/php5/soundex2.cls.php';
$soundex2 = new soundex2;
$aCheck = array ('MALLEIN','MOLEINS', 'MOLIN', 'MOULIN', 'NAULIN', 'GRAU', 'GROS', 'GROSS', 'GROZ', 'GRAS', 'GRASS',
'ROUSSEAU', 'ROUSSEAUX', 'ROUSSOT', 'RASSAT', 'RASSSAT', 'ROSSAT', 'ROSSO'
);
$sString = 'rousseau';
$soundex2 -> build ($sString);
$sSoundex = $soundex2 -> sString;
foreach ($aCheck as $clef => $val) {
$soundex2 -> build ($val);
$level = levenshtein (strtolower ($sString), strtolower ($val));
if ($soundex2 -> sString === $sSoundex) {
$aWords[] = $val;
$aDistance[] = $level;
}
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);
echo 'Soundex2 checked for [', $sString, '] these entries : <br />';
echo '<pre>', print_r ($aChecked), '</pre>';
$aChecked = $aWords = $aDistance = array ();
$sString = 'moulin';
$soundex2 -> build ($sString);
$sSoundex = $soundex2 -> sString;
foreach ($aCheck as $clef => $val) {
$soundex2 -> build ($val);
$level = levenshtein (strtolower ($sString), strtolower ($val));
if ($soundex2 -> sString === $sSoundex) {
$aWords[] = $val;
$aDistance[] = $level;
}
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);
echo 'Soundex2 checked for [', $sString, '] these entries : <br />';
echo '<pre>', print_r ($aChecked), '</pre>';
$aChecked = $aWords = $aDistance = array ();
$sString = 'gros';
$soundex2 -> build ($sString);
$sSoundex = $soundex2 -> sString;
foreach ($aCheck as $clef => $val) {
$soundex2 -> build ($val);
$level = levenshtein (strtolower ($sString), strtolower ($val));
if ($soundex2 -> sString === $sSoundex) {
$aWords[] = $val;
$aDistance[] = $level;
}
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);
echo 'Soundex2 checked for [', $sString, '] these entries : <br />';
echo '<pre>', print_r ($aChecked), '</pre>';
?>
|