protected function find_matches($pk, $last, $first, $middle, &$names, &$pks) { if (strlen($last) < 2) { return; } $pfx = mb_substr($last, 0, 2, 'UTF-8'); $stmt = $this->db->query('select person_pk, name_last, name_first, name_middle from person where name_last like :pfxpat and person_pk != :pk and replacedby_fk is null order by name_last, name_first, name_middle', array('pfxpat' => "{$pfx}%", 'pk' => $pk)); while ($row = $stmt->fetch()) { $jw1 = JaroWinkler($last, $row['name_last'], true); if (empty($first)) { $jw2 = $jw3 = $jw4 = 1; } else { $name1 = explode(' ', trim($first)); $name2 = explode(' ', trim($row['name_first'])); $jw2 = JaroWinkler($name1[0], $name2[0], true); $jw3 = JaroWinkler($name1[0], $row['name_middle'], true); $jw4 = JaroWinkler($name2[0], $middle, true); } if ($jw1 > 0.9 && ($jw2 > 0.75 || $jw3 > 0.75 || $jw4 > 0.75)) { $names[] = $this->build_name($row); $pks[] = $row['person_pk']; } } }
print "\n"; print JaroWinkler($target, $candidate); print "\n"; $target = "Sutonska"; $candidate = "Sotonska"; printf("%s ~ %s\n", $target, $candidate); print Jaro($target, $candidate); print "\n"; print JaroWinkler($target, $candidate); print "\n"; $target = "Ves"; $candidate = "Vel"; printf("%s ~ %s\n", $target, $candidate); print Jaro($target, $candidate); print "\n"; print JaroWinkler($target, $candidate); print "\n"; $target = "Radić"; $candidate = "Tadić"; printf("%s ~ %s\n", $target, $candidate); print Jaro($target, $candidate); print "\n"; print JaroWinkler($target, $candidate); print "\n"; $target = "Međimurska"; $candidate = "Međimurje"; printf("%s ~ %s\n", $target, $candidate); print Jaro($target, $candidate); print "\n"; print JaroWinkler($target, $candidate); print "\n";
$xTbl->addRaw("<td /><td />"); break; case "jarowinkler": $flTitle = $xLng->getT("TR.Algoritmo") . " : JARO-WINKLER"; $xTbl->addTH($xLng->getT("TR.Coincidencia")); $score1 = 0; $score2 = 0; $score3 = 0; if ($nombre != "") { $score1 = JaroWinkler($nombre, $noms); } if ($amaterno != "") { $score3 = JaroWinkler($amaterno, $app2); } if ($apaterno != "") { $score2 = JaroWinkler($apaterno, $app1); } //JaroWinkler($string1, $string2) $xTbl->addTD("{$score1} / {$score2} / {$score3}"); break; case "metaphone": $flTitle = $xLng->getT("TR.Algoritmo") . " : METAPHONE"; $xTbl->addTH($xLng->getT("TR.Coincidencia")); $score1 = ""; $score2 = ""; $score3 = ""; if ($nombre != "") { $score1 = metaphone($nombre) . "/" . metaphone($noms); } if ($amaterno != "") { $score3 = metaphone($amaterno) . "/" . metaphone($app2);