$aDBWords = $this->oDB->getAll($sSQL, null, 'Could not get word tokens.');
foreach ($aDBWords as $aWord) {
+ $iId = (int) $aWord['word_id'];
+
switch ($aWord['type']) {
'C': // country name tokens
if ($aWord['country'] === null
}
$oToken = new Token\Country($iId, $aWord['country'])
break;
+ 'H': // house number tokens
+ $oToken = new Token\HouseNumber($iId, $aWord['word_token']);
+ break;
default:
continue;
}
-/* $iId = (int) $aWord['word_id'];
-
- if ($aWord['class']) {
+/* if ($aWord['class']) {
// Special terms need to appear in their normalized form.
// (postcodes are not normalized in the word table)
$sNormWord = $this->normalizeString($aWord['word']);
DECLARE
return_id INTEGER;
BEGIN
- SELECT min(word_id) INTO return_id
- FROM word
- WHERE word_token = ' ' || lookup_term
- and class = 'place' and type = 'house';
+ SELECT min(word_id) INTO return_id FROM word
+ WHERE word_token = lookup_term and type = 'H';
IF return_id IS NULL THEN
return_id := nextval('seq_word');
- INSERT INTO word (word_id, word_token, class, type, search_name_count)
- VALUES (return_id, ' ' || lookup_term, 'place', 'house', 0);
+ INSERT INTO word (word_id, word_token, type)
+ VALUES (return_id, lookup_term, 'H');
END IF;
RETURN return_id;
def get_hnr_tokens(self, conn, terms):
""" Get token ids for a list of housenumbers, looking them up in the
- database if necessary.
+ database if necessary. `terms` is an iterable of normalized
+ housenumbers.
"""
tokens = []
askdb = []