]> git.openstreetmap.org Git - nominatim.git/commitdiff
experimental tweaking of ranks of searches
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 1 May 2014 15:53:13 +0000 (17:53 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 1 May 2014 15:53:13 +0000 (17:53 +0200)
- completely removes partial words with spaces from addresses
- ensure that frequent partial search terms appear in NonAddress
- higher penalty for partial words consisting of numbers

lib/Geocode.php

index dd75b3a73fb0a318542b1041998f356881e615ea..8616be1378b7041b0b0531bb69b6ec9b40e7da28 100644 (file)
                                                                                {
                                                                                        if (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id'])
                                                                                        {
-                                                                                               if ((!$bStructuredPhrases || $iPhrase > 0) && sizeof($aCurrentSearch['aName']) && strlen($sToken) >= 4)
+                                                                                               if ((!$bStructuredPhrases || $iPhrase > 0) && sizeof($aCurrentSearch['aName']) && strpos($sToken, ' ') === false)
                                                                                                {
                                                                                                        $aSearch = $aCurrentSearch;
                                                                                                        $aSearch['iSearchRank'] += 1;
                                                                                                                $aSearch['aAddress'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
                                                                                                                if ($aSearch['iSearchRank'] < $this->iMaxRank) $aNewWordsetSearches[] = $aSearch;
                                                                                                        }
-                                                                                                       elseif (isset($aValidTokens[' '.$sToken])) // revert to the token version?
+                                                                                                       elseif (isset($aValidTokens[' '.$sToken]) && strlen($sToken) >= 4) // revert to the token version?
                                                                                                        {
+                                                                                                               $aSearch['aAddressNonSearch'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+                                                                                                               $aSearch['iSearchRank'] += 1;
+                                                                                                               if ($aSearch['iSearchRank'] < $this->iMaxRank) $aNewWordsetSearches[] = $aSearch;
                                                                                                                foreach($aValidTokens[' '.$sToken] as $aSearchTermToken)
                                                                                                                {
                                                                                                                        if (empty($aSearchTermToken['country_code'])
                                                                                                        else
                                                                                                        {
                                                                                                                $aSearch['aAddressNonSearch'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+                                                                                                               if (preg_match('#^[0-9]+$#', $sToken)) $aSearch['iSearchRank'] += 2;
                                                                                                                if ($aSearch['iSearchRank'] < $this->iMaxRank) $aNewWordsetSearches[] = $aSearch;
                                                                                                        }
                                                                                                }
                                                                                                if (!sizeof($aCurrentSearch['aName']) || $aCurrentSearch['iNamePhrase'] == $iPhrase)
                                                                                                {
                                                                                                        $aSearch = $aCurrentSearch;
-                                                                                                       $aSearch['iSearchRank'] += 2;
+                                                                                                       $aSearch['iSearchRank'] += 1;
+                                                                                                       if (!sizeof($aCurrentSearch['aName'])) $aSearch['iSearchRank'] += 1;
                                                                                                        if (preg_match('#^[0-9]+$#', $sToken)) $aSearch['iSearchRank'] += 2;
                                                                                                        if ($aWordFrequencyScores[$aSearchTerm['word_id']] < CONST_Max_Word_Frequency)
                                                                                                                $aSearch['aName'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];