mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-15 10:57:58 +00:00
give slight preference to full-word matches when reranking
fixes https://trac.openstreetmap.org/ticket/5094
This commit is contained in:
@@ -1566,7 +1566,7 @@
|
||||
}
|
||||
|
||||
$aClassType = getClassTypesWithImportance();
|
||||
$aRecheckWords = preg_split('/\b/u',$sQuery);
|
||||
$aRecheckWords = preg_split('/\b[\s,\\-]*/u',$sQuery);
|
||||
foreach($aRecheckWords as $i => $sWord)
|
||||
{
|
||||
if (!$sWord) unset($aRecheckWords[$i]);
|
||||
@@ -1727,7 +1727,11 @@
|
||||
$sAddress = $aResult['langaddress'];
|
||||
foreach($aRecheckWords as $i => $sWord)
|
||||
{
|
||||
if (stripos($sAddress, $sWord)!==false) $iCountWords++;
|
||||
if (stripos($sAddress, $sWord)!==false)
|
||||
{
|
||||
$iCountWords++;
|
||||
if (preg_match("/(^|,)\s*$sWord\s*(,|$)/", $sAddress)) $iCountWords += 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
$aResult['importance'] = $aResult['importance'] + ($iCountWords*0.1); // 0.1 is a completely arbitrary number but something in the range 0.1 to 0.5 would seem right
|
||||
|
||||
Reference in New Issue
Block a user