]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/TokenList.php
improve handling of multi-word partials in SearchDescription
[nominatim.git] / lib / TokenList.php
index fce5f940b84513a6bc1850cbbbdb5e9fa043682c..78fa6444af63ccf3f90d787cb1498560fbb44a52 100644 (file)
@@ -80,6 +80,21 @@ class TokenList
         return isset($this->aTokens[$sWord]) ? $this->aTokens[$sWord] : array();
     }
 
+    public function getFullWordIDs()
+    {
+        $ids = array();
+
+        foreach($this->aTokens as $aTokenList) {
+            foreach($aTokenList as $oToken) {
+                if (is_a($oToken, '\Nominatim\Token\Word') && !$oToken->bPartial) {
+                    $ids[$oToken->iId] = $oToken->iId;
+                }
+            }
+        }
+
+        return $ids;
+    }
+
     /**
      * Add token information from the word table in the database.
      *
@@ -151,7 +166,8 @@ class TokenList
                 $oToken = new Token\Word(
                     $iId,
                     $aWord['word_token'][0] != ' ',
-                    (int) $aWord['count']
+                    (int) $aWord['count'],
+                    substr_count($aWord['word_token'], ' ')
                 );
             }