3 namespace Nominatim\Token;
6 * A standard word token.
10 /// Database word id, if applicable.
12 /// Number of appearances in the database.
13 private $iSearchNameCount;
14 /// Number of terms in the word.
17 public function __construct($iId, $iSearchNameCount, $iTermCount)
20 $this->iSearchNameCount = $iSearchNameCount;
21 $this->iTermCount = $iTermCount;
24 public function getId()
30 * Check if the token can be added to the given search.
31 * Derive new searches by adding this token to an existing search.
33 * @param object $oSearch Partial search description derived so far.
34 * @param object $oPosition Description of the token position within
37 * @return True if the token is compatible with the search configuration
40 public function isExtendable($oSearch, $oPosition)
42 return !$oPosition->isPhrase('country');
46 * Derive new searches by adding this token to an existing search.
48 * @param object $oSearch Partial search description derived so far.
49 * @param object $oPosition Description of the token position within
52 * @return SearchDescription[] List of derived search descriptions.
54 public function extendSearch($oSearch, $oPosition)
56 // Full words can only be a name if they appear at the beginning
57 // of the phrase. In structured search the name must forcably in
58 // the first phrase. In unstructured search it may be in a later
59 // phrase when the first phrase is a house number.
60 if ($oSearch->hasName()
61 || !($oPosition->isFirstPhrase() || $oPosition->isPhrase(''))
63 if ($this->iTermCount > 1
64 && ($oPosition->isPhrase('') || !$oPosition->isFirstPhrase())
66 $oNewSearch = $oSearch->clone(1);
67 $oNewSearch->addAddressToken($this->iId);
69 return array($oNewSearch);
71 } elseif (!$oSearch->hasName(true)) {
72 $oNewSearch = $oSearch->clone(1);
73 $oNewSearch->addNameToken(
75 CONST_Search_NameOnlySearchFrequencyThreshold
76 && $this->iSearchNameCount
77 < CONST_Search_NameOnlySearchFrequencyThreshold
80 return array($oNewSearch);
86 public function debugInfo()
92 'count' => $this->iSearchNameCount,
93 'terms' => $this->iTermCount
98 public function debugCode()