From 942ed125d4c7f93a741166cfeacf8d6115623e8d Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Tue, 5 Apr 2011 14:51:32 +0000 Subject: [PATCH] consider possibility that values with number in near start of search might be a house number (even if we have never seen them before). Also add better label for building:yes --- lib/lib.php | 1 + lib/template/search-html.php | 5 ++++- website/search.php | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/lib.php b/lib/lib.php index 1a320a18..7f56a1de 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -568,6 +568,7 @@ 'amenity:shopping' => array('label'=>'Shopping','frequency'=>21,'icon'=>'',), 'natural:scrub' => array('label'=>'Scrub','frequency'=>20,'icon'=>'',), 'natural:fen' => array('label'=>'Fen','frequency'=>20,'icon'=>'',), + 'building:yes' => array('label'=>'Building','frequency'=>200,'icon'=>'',), 'amenity:parking' => array('label'=>'Parking','frequency'=>3157,'icon'=>'',), 'highway:bus_stop' => array('label'=>'Bus Stop','frequency'=>35777,'icon'=>'transport_bus_stop2',), diff --git a/lib/template/search-html.php b/lib/template/search-html.php index 986b4e4d..f7013793 100644 --- a/lib/template/search-html.php +++ b/lib/template/search-html.php @@ -372,7 +372,10 @@ target="_blank">FAQ echo ' '.$aResult['name'].''; echo ' '.round($aResult['lat'],3).','.round($aResult['lat'],3).''; echo ' '.$aResult['place_id'].''; - echo ' ('.ucwords(str_replace('_',' ',$aResult['type'])).')'; + if (isset($aResult['label'])) + echo ' ('.$aResult['label'].')'; + else + echo ' ('.ucwords(str_replace('_',' ',$aResult['type'])).')'; echo ' (details)'; echo ''; } diff --git a/website/search.php b/website/search.php index 6a997acb..070ca524 100755 --- a/website/search.php +++ b/website/search.php @@ -278,7 +278,7 @@ { unset($aPhrases[$iPhrase]); } - } + } // reindex phrases - we make assumptions later on $aPhrases = array_values($aPhrases); @@ -366,6 +366,16 @@ } } */ + + foreach($aTokens as $sToken) + { + // Unknown single word token with a number - assume it is a house number + if (!isset($aValidTokens[' '.$sToken]) && strpos($sToken,' ') === false && preg_match('/[0-9]/', $sToken)) + { + $aValidTokens[' '.$sToken] = array('class'=>'place','type'=>'house'); + } + } + // Any words that have failed completely? // TODO: suggestions @@ -1094,6 +1104,12 @@ $aResult['icon'] = CONST_Website_BaseURL.'images/mapicons/'.$aClassType[$aResult['class'].':'.$aResult['type']]['icon'].'.p.20.png'; } + if (isset($aClassType[$aResult['class'].':'.$aResult['type']]['label']) + && $aClassType[$aResult['class'].':'.$aResult['type']]['label']) + { + $aResult['label'] = $aClassType[$aResult['class'].':'.$aResult['type']]['label']; + } + if ($bShowAddressDetails) { $aResult['address'] = getAddressDetails($oDB, $sLanguagePrefArraySQL, $aResult['place_id'], $aResult['country_code']); -- 2.39.5