Warning: Invalid argument supplied for foreach() in /home/jihswbiz/public_html/t6.gwilt.org/refDox.php on line 212
Docs-in_dict

 

ReLoad

Keys


Functions

arraybrowsercolorcookiedatetimeDBdebugdeviceDSTequiverrorflagsfontformatgeo
holidayhtmlisjsonmathparsePHPprintsearchsortstringtabletexttracetype
VOTDweatherxml

Function  in_dict   Lines 1319-1344 (25 lines) file  utils.php   Last mod: Fri 2021-05-14 21:45:07

function in_dict $input$dict )
        {
#-k     search
#-      return the closest-sounding word to $input in $dict

        
$shortest = -1;

        foreach (
$dict as $word)
                {       
# loop through dictionary to find the closest
                
$lev levenshtein $input$word );   # calculate the distance between the input word, and the current word
                
if ($lev == 0)
                        {               
# check for an exact match
                        
$closest 0;   # closest word is this one (exact match)
                        
break;          # break out of the loop; we've found an exact match
                        
}

                if (
$lev $shortest || $shortest 0)
                        {
                        
$closest  $word;
                        
$shortest $lev;
                        }
                }

        return 
$closest;        # 0 or the closest word
        
}

?>