mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-27 10:43:02 +03:00
simplify cross-check of country tokens
Drop country tokens that do not match the country code list early. Remove in turn the special country code check for structured phrases. It is sufficient to do this during word list building.
This commit is contained in:
parent
9ef2370a2a
commit
77b76ae51b
@ -802,7 +802,7 @@ class Geocode
|
|||||||
// Revisit searches, drop bad searches and give penalty to unlikely combinations.
|
// Revisit searches, drop bad searches and give penalty to unlikely combinations.
|
||||||
$aGroupedSearches = array();
|
$aGroupedSearches = array();
|
||||||
foreach ($aSearches as $oSearch) {
|
foreach ($aSearches as $oSearch) {
|
||||||
if (!$oSearch->isValidSearch($this->aCountryCodes)) {
|
if (!$oSearch->isValidSearch()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -991,9 +991,10 @@ class Geocode
|
|||||||
);
|
);
|
||||||
$aWordFrequencyScores = array();
|
$aWordFrequencyScores = array();
|
||||||
foreach ($aDatabaseWords as $aToken) {
|
foreach ($aDatabaseWords as $aToken) {
|
||||||
// Very special case - require 2 letter country param to match the country code found
|
// Filter country tokens that do not match restricted countries.
|
||||||
if ($bStructuredPhrases && $aToken['country_code'] && !empty($this->aStructuredQuery['country'])
|
if ($this->aCountryCodes
|
||||||
&& strlen($this->aStructuredQuery['country']) == 2 && strtolower($this->aStructuredQuery['country']) != $aToken['country_code']
|
&& $aToken['country_code']
|
||||||
|
&& !in_array($aToken['country_code'], $this->aCountryCodes)
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -155,22 +155,17 @@ class SearchDescription
|
|||||||
/**
|
/**
|
||||||
* Check if the combination of parameters is sensible.
|
* Check if the combination of parameters is sensible.
|
||||||
*
|
*
|
||||||
* @param string[] $aCountryCodes List of country codes.
|
|
||||||
*
|
|
||||||
* @return bool True, if the search looks valid.
|
* @return bool True, if the search looks valid.
|
||||||
*/
|
*/
|
||||||
public function isValidSearch(&$aCountryCodes)
|
public function isValidSearch()
|
||||||
{
|
{
|
||||||
if (!sizeof($this->aName)) {
|
if (!sizeof($this->aName)) {
|
||||||
if ($this->sHouseNumber) {
|
if ($this->sHouseNumber) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
if (!$this->sClass && !$this->sCountryCode) {
|
||||||
if ($aCountryCodes
|
return false;
|
||||||
&& $this->sCountryCode
|
}
|
||||||
&& !in_array($this->sCountryCode, $aCountryCodes)
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -302,7 +297,10 @@ class SearchDescription
|
|||||||
$oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']);
|
$oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']);
|
||||||
$aNewSearches[] = $oSearch;
|
$aNewSearches[] = $oSearch;
|
||||||
}
|
}
|
||||||
} elseif (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id']) {
|
} elseif (isset($aSearchTerm['word_id'])
|
||||||
|
&& $aSearchTerm['word_id']
|
||||||
|
&& $sPhraseType != 'country'
|
||||||
|
) {
|
||||||
$iWordID = $aSearchTerm['word_id'];
|
$iWordID = $aSearchTerm['word_id'];
|
||||||
if (sizeof($this->aName)) {
|
if (sizeof($this->aName)) {
|
||||||
if (($sPhraseType == '' || !$bFirstPhrase)
|
if (($sPhraseType == '' || !$bFirstPhrase)
|
||||||
|
Loading…
Reference in New Issue
Block a user