From 760807c5e04c427d8df616991b18c78f72a10b04 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Tue, 24 Oct 2017 22:42:29 +0200 Subject: [PATCH] revert use of global penalty for a search direction Adding a penalty to a search description because there is a term at the beginning which looks like a country turned out to be a bad idea as there are too many abbreviations around that match against frequently matched words. --- lib/Geocode.php | 6 +----- lib/SearchDescription.php | 23 +---------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index ae518d51..4072aae2 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -345,8 +345,6 @@ class Geocode Score how good the search is so they can be ordered */ - $iGlobalRank = 0; - foreach ($aPhrases as $iPhrase => $oPhrase) { $aNewPhraseSearches = array(); $sPhraseType = $bIsStructured ? $oPhrase->getPhraseType() : ''; @@ -378,8 +376,7 @@ class Geocode $iToken == 0 && $iPhrase == 0, $iPhrase == 0, $iToken + 1 == sizeof($aWordset) - && $iPhrase + 1 == sizeof($aPhrases), - $iGlobalRank + && $iPhrase + 1 == sizeof($aPhrases) ); foreach ($aNewSearches as $oSearch) { @@ -460,7 +457,6 @@ class Geocode continue; } - $iRank = $oSearch->addToRank($iGlobalRank); if (!isset($aGroupedSearches[$iRank])) { $aGroupedSearches[$iRank] = array(); } diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php index 56d04478..e9495852 100644 --- a/lib/SearchDescription.php +++ b/lib/SearchDescription.php @@ -68,19 +68,6 @@ class SearchDescription return $this->iSearchRank; } - /** - * Increase the search rank. - * - * @param integer $iAddRank Number of ranks to increase. - * - * @return void - */ - public function addToRank($iAddRank) - { - $this->iSearchRank += $iAddRank; - return $this->iSearchRank; - } - /** * Make this search a POI search. * @@ -187,12 +174,10 @@ class SearchDescription * @param bool $bFirstPhrase True if the token is in the first phrase of * the query. * @param bool $bLastToken True if the token is at the end of the query. - * @param integer $iGlobalRank Changable ranking of all searches in the - * batch. * * @return SearchDescription[] List of derived search descriptions. */ - public function extendWithFullTerm($aSearchTerm, $bHasPartial, $sPhraseType, $bFirstToken, $bFirstPhrase, $bLastToken, &$iGlobalRank) + public function extendWithFullTerm($aSearchTerm, $bHasPartial, $sPhraseType, $bFirstToken, $bFirstPhrase, $bLastToken) { $aNewSearches = array(); @@ -210,12 +195,6 @@ class SearchDescription $oSearch->iSearchRank += 5; } $aNewSearches[] = $oSearch; - - // If it is at the beginning, we can be almost sure that - // the terms are in the wrong order. Increase score for all searches. - if ($bFirstToken) { - $iGlobalRank++; - } } } elseif (($sPhraseType == '' || $sPhraseType == 'postalcode') && $aSearchTerm['class'] == 'place' && $aSearchTerm['type'] == 'postcode' -- 2.45.1