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 * Derive new searches by adding this token to an existing search.
32 * @param object $oSearch Partial search description derived so far.
33 * @param object $oPosition Description of the token position within
36 * @return SearchDescription[] List of derived search descriptions.
38 public function extendSearch($oSearch, $oPosition)
40 if ($oPosition->isPhrase('country')) {
44 // Full words can only be a name if they appear at the beginning
45 // of the phrase. In structured search the name must forcably in
46 // the first phrase. In unstructured search it may be in a later
47 // phrase when the first phrase is a house number.
48 if ($oSearch->hasName()
49 || !($oPosition->isFirstPhrase() || $oPosition->isPhrase(''))
51 if ($this->iTermCount > 1
52 && ($oPosition->isPhrase('') || !$oPosition->isFirstPhrase())
54 $oNewSearch = $oSearch->clone(1);
55 $oNewSearch->addAddressToken($this->iId);
57 return array($oNewSearch);
59 } elseif (!$oSearch->hasName(true)) {
60 $oNewSearch = $oSearch->clone(1);
61 $oNewSearch->addNameToken($this->iId);
62 if (CONST_Search_NameOnlySearchFrequencyThreshold
63 && $this->iSearchNameCount
64 < CONST_Search_NameOnlySearchFrequencyThreshold
66 $oNewSearch->markRareName();
69 return array($oNewSearch);
75 public function debugInfo()
81 'count' => $this->iSearchNameCount,
82 'terms' => $this->iTermCount
87 public function debugCode()