switch housenumber tokens to new word table layout

This commit is contained in:
Sarah Hoffmann
2021-07-20 11:36:20 +02:00
parent 1618aba5f2
commit 5ab0a63fd6
3 changed files with 12 additions and 10 deletions

View File

@@ -156,6 +156,8 @@ class Tokenizer
$aDBWords = $this->oDB->getAll($sSQL, null, 'Could not get word tokens.'); $aDBWords = $this->oDB->getAll($sSQL, null, 'Could not get word tokens.');
foreach ($aDBWords as $aWord) { foreach ($aDBWords as $aWord) {
$iId = (int) $aWord['word_id'];
switch ($aWord['type']) { switch ($aWord['type']) {
'C': // country name tokens 'C': // country name tokens
if ($aWord['country'] === null if ($aWord['country'] === null
@@ -166,12 +168,13 @@ class Tokenizer
} }
$oToken = new Token\Country($iId, $aWord['country']) $oToken = new Token\Country($iId, $aWord['country'])
break; break;
'H': // house number tokens
$oToken = new Token\HouseNumber($iId, $aWord['word_token']);
break;
default: default:
continue; continue;
} }
/* $iId = (int) $aWord['word_id']; /* if ($aWord['class']) {
if ($aWord['class']) {
// Special terms need to appear in their normalized form. // Special terms need to appear in their normalized form.
// (postcodes are not normalized in the word table) // (postcodes are not normalized in the word table)
$sNormWord = $this->normalizeString($aWord['word']); $sNormWord = $this->normalizeString($aWord['word']);

View File

@@ -140,15 +140,13 @@ CREATE OR REPLACE FUNCTION getorcreate_hnr_id(lookup_term TEXT)
DECLARE DECLARE
return_id INTEGER; return_id INTEGER;
BEGIN BEGIN
SELECT min(word_id) INTO return_id SELECT min(word_id) INTO return_id FROM word
FROM word WHERE word_token = lookup_term and type = 'H';
WHERE word_token = ' ' || lookup_term
and class = 'place' and type = 'house';
IF return_id IS NULL THEN IF return_id IS NULL THEN
return_id := nextval('seq_word'); return_id := nextval('seq_word');
INSERT INTO word (word_id, word_token, class, type, search_name_count) INSERT INTO word (word_id, word_token, type)
VALUES (return_id, ' ' || lookup_term, 'place', 'house', 0); VALUES (return_id, lookup_term, 'H');
END IF; END IF;
RETURN return_id; RETURN return_id;

View File

@@ -601,7 +601,8 @@ class _TokenCache:
def get_hnr_tokens(self, conn, terms): def get_hnr_tokens(self, conn, terms):
""" Get token ids for a list of housenumbers, looking them up in the """ 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 = [] tokens = []
askdb = [] askdb = []