PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Johan Barbier  >  Phonex  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: index example page
Class: Phonex
Implementation of the phonex algorithm for French
Author: By
Last change: Changed path
Date: 9 years ago
Size: 1,962 bytes
 

Contents

Class file image Download
<?php
require_once 'class/php5/phonex.cls.php';
$oPhonex = new phonex;

$aCheck = array ('MALLEIN','MOLEINS', 'MOLIN', 'MOULIN', 'NAULIN', 'GRAU', 'GROS', 'GROSS', 'GROZ', 'GRAS', 'GRASS',
'ROUSSEAU', 'ROUSSEAUX', 'ROUSSOT', 'RASSAT', 'RASSSAT', 'ROSSAT', 'ROSSO'
);

$sString = 'rousseau';

$oPhonex -> build ($sString);
$sPhonex = $oPhonex -> sString;

foreach (
$aCheck as $clef => $val) {
   
$oPhonex -> build ($val);
   
$level = levenshtein (strtolower ($sString), strtolower ($val) );
    if (
$oPhonex -> sString === $sPhonex) {
       
$aWords[] = $val;
       
$aDistance[] = $level;
    }
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);


echo
'Phonex checked for [', $sString, '] these entries : <br />';
echo
'<pre>', print_r ($aChecked), '</pre>';


$aChecked = $aWords = $aDistance = array ();


$sString = 'gros';
$oPhonex -> build ($sString);
$sPhonex = $oPhonex -> sString;

foreach (
$aCheck as $clef => $val) {
   
$oPhonex -> build ($val);
   
$level = levenshtein (strtolower ($sString), strtolower ($val) );
    if (
$oPhonex -> sString === $sPhonex) {
       
$aWords[] = $val;
       
$aDistance[] = $level;
    }
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);

echo
'Phonex checked for [', $sString, '] these entries : <br />';
echo
'<pre>', print_r ($aChecked), '</pre>';

$aChecked = $aWords = $aDistance = array ();


$sString = 'moulin';
$oPhonex -> build ($sString);
$sPhonex = $oPhonex -> sString;

foreach (
$aCheck as $clef => $val) {
   
$oPhonex -> build ($val);
   
$level = levenshtein (strtolower ($sString), strtolower ($val) );
    if (
$oPhonex -> sString === $sPhonex) {
       
$aWords[] = $val;
       
$aDistance[] = $level;
    }
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);
echo
'Phonex checked for [', $sString, '] these entries : <br />';
echo
'<pre>', print_r ($aChecked), '</pre>';

?>