mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +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();
|
$aClassType = getClassTypesWithImportance();
|
||||||
$aRecheckWords = preg_split('/\b/u',$sQuery);
|
$aRecheckWords = preg_split('/\b[\s,\\-]*/u',$sQuery);
|
||||||
foreach($aRecheckWords as $i => $sWord)
|
foreach($aRecheckWords as $i => $sWord)
|
||||||
{
|
{
|
||||||
if (!$sWord) unset($aRecheckWords[$i]);
|
if (!$sWord) unset($aRecheckWords[$i]);
|
||||||
@@ -1727,7 +1727,11 @@
|
|||||||
$sAddress = $aResult['langaddress'];
|
$sAddress = $aResult['langaddress'];
|
||||||
foreach($aRecheckWords as $i => $sWord)
|
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
|
$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