<?php
include("libphonetiq.class.php");
#Search query
$query = "firewall training";
#Set of data
$data = array(
'McAfee training'=>array(
'Course Name'=>'McAfee Training Course V1',
'Product'=>'McAfee Antivirus'
),
'Sponge class'=>array(
'Course Name'=>'Sponges 101',
'Product'=>'Mayonaise'
),
'Train spotting'=>array(
'Course Name'=>'Spotting trains for dummies',
'Product'=>'Trains'
)
);
$engine = new PhonetiQ();
$start = microtime(true);
print "Searching in dataset for '$query'... <br/>";
$engine->begin($query);
foreach ($data as $key=>$row)
{
$score = $engine->next($row);
if ($score === false)
print " $key - Not in results <br/>";
else
print " $key - $score <br/>";
}
print "Finished in " . (microtime(true) - $start);
?>
|