From: Sarah Hoffmann Date: Fri, 3 Sep 2021 12:16:23 +0000 (+0200) Subject: Merge pull request #2437 from lonvia/tweak-ranking-searches X-Git-Tag: v4.0.0~32 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/18554dfed767d8ef669e15014a5b0382ad8bab43?hp=2e493fec469b130f97addba94d2834f6e9099672 Merge pull request #2437 from lonvia/tweak-ranking-searches Some more tweaks for search interpretation --- diff --git a/lib-php/TokenHousenumber.php b/lib-php/TokenHousenumber.php index cd60d3ca..f7bdc471 100644 --- a/lib-php/TokenHousenumber.php +++ b/lib-php/TokenHousenumber.php @@ -59,7 +59,7 @@ class HouseNumber $iSearchCost = 1; if (preg_match('/\\d/', $this->sToken) === 0 || preg_match_all('/[^0-9]/', $this->sToken, $aMatches) > 2) { - $iSearchCost++; + $iSearchCost += strlen($this->sToken) - 1; } if (!$oSearch->hasOperator(\Nominatim\Operator::NONE)) { $iSearchCost++; diff --git a/lib-php/TokenSpecialTerm.php b/lib-php/TokenSpecialTerm.php index 5b2d4c70..6eb2ede3 100644 --- a/lib-php/TokenSpecialTerm.php +++ b/lib-php/TokenSpecialTerm.php @@ -44,7 +44,10 @@ class SpecialTerm */ public function isExtendable($oSearch, $oPosition) { - return !$oSearch->hasOperator() && $oPosition->isPhrase(''); + return !$oSearch->hasOperator() + && $oPosition->isPhrase('') + && ($this->iOperator != \Nominatim\Operator::NONE + || (!$oSearch->hasAddress() && !$oSearch->hasHousenumber() && !$oSearch->hasCountry())); } /** @@ -66,8 +69,8 @@ class SpecialTerm $iOp = \Nominatim\Operator::NAME; } else { $iOp = \Nominatim\Operator::NEAR; + $iSearchCost += 2; } - $iSearchCost += 2; } elseif (!$oPosition->isFirstToken() && !$oPosition->isLastToken()) { $iSearchCost += 2; }