]> git.openstreetmap.org Git - nominatim.git/commitdiff
remove penalty for full words in address
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 26 Jun 2021 09:20:25 +0000 (11:20 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 26 Jun 2021 09:37:15 +0000 (11:37 +0200)
Now that mutli-word partials no longer exist, multi-word full
words need to be used to search in addresses and therefore no
longer should have a penalty.

Also changes the condition when a full word is included into
the address. It is no longer relevant if an equivalent partial
exists but only if the term consists of more than one word.

lib-php/Geocode.php
lib-php/SearchDescription.php

index 53ee49c043f53d80434887978434998987f9c830..a3883b2509fdc3477881f1f06b87ff9dfb9509bd 100644 (file)
@@ -348,8 +348,6 @@ class Geocode
                         foreach ($oValidTokens->get(' '.$sToken) as $oSearchTerm) {
                             $aNewSearches = $oCurrentSearch->extendWithFullTerm(
                                 $oSearchTerm,
-                                $oValidTokens->contains($sToken)
-                                  && strpos($sToken, ' ') === false,
                                 $sPhraseType,
                                 $iToken == 0 && $iPhrase == 0,
                                 $iPhrase == 0,
index 44d3a2a5033998a0065a9859ec701057105cb3b0..3c572f2fc872e1e41a47580b80d156834870b964 100644 (file)
@@ -153,8 +153,6 @@ class SearchDescription
      * Derive new searches by adding a full term to the existing search.
      *
      * @param object $oSearchTerm  Description of the token.
-     * @param bool   $bHasPartial  True if there are also tokens of partial terms
-     *                             with the same name.
      * @param string $sPhraseType  Type of phrase the token is contained in.
      * @param bool   $bFirstToken  True if the token is at the beginning of the
      *                             query.
@@ -164,7 +162,7 @@ class SearchDescription
      *
      * @return SearchDescription[] List of derived search descriptions.
      */
-    public function extendWithFullTerm($oSearchTerm, $bHasPartial, $sPhraseType, $bFirstToken, $bFirstPhrase, $bLastToken)
+    public function extendWithFullTerm($oSearchTerm, $sPhraseType, $bFirstToken, $bFirstPhrase, $bLastToken)
     {
         $aNewSearches = array();
 
@@ -244,6 +242,7 @@ class SearchDescription
                 $oSearch->iNamePhrase = -1;
                 $oSearch->sHouseNumber = $oSearchTerm->sToken;
                 $aNewSearches[] = $oSearch;
+
                 // Housenumbers may appear in the name when the place has its own
                 // address terms.
                 if ($oSearchTerm->iId !== null
@@ -297,10 +296,10 @@ class SearchDescription
             // the first phrase. In unstructured search it may be in a later
             // phrase when the first phrase is a house number.
             if (!empty($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
-                if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) {
+                if (($sPhraseType == '' || !$bFirstPhrase) && $oSearchTerm->iTermCount > 1) {
                     $oSearch = clone $this;
                     $oSearch->iNamePhrase = -1;
-                    $oSearch->iSearchRank += 3 * $oSearchTerm->iTermCount;
+                    $oSearch->iSearchRank += 1;
                     $oSearch->aAddress[$iWordID] = $iWordID;
                     $aNewSearches[] = $oSearch;
                 }