Introduction of PyICU for transliteration in python. Reversed changes in normalization.sql.

This commit is contained in:
AntoJvlt 2021-03-22 00:58:49 +01:00
parent 2fb6018078
commit 1ce8b530cd
7 changed files with 177 additions and 166 deletions

View File

@ -6,7 +6,8 @@ runs:
steps:
- name: Install prerequisites
run: |
sudo apt-get install -y -qq libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev python3-psycopg2 python3-pyosmium python3-dotenv python3-psutil python3-jinja2
sudo apt-get install -y -qq libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev libicu-dev python3-psycopg2 python3-pyosmium python3-dotenv python3-psutil python3-jinja2
sudo pip install PyICU
shell: bash
- name: Download dependencies

View File

@ -8,4 +8,4 @@ loadSettings(getcwd());
(new \Nominatim\Shell(getSetting('NOMINATIM_TOOL')))
->addParams('import-special-phrases', '--from-wiki')
->run();
->run();

View File

@ -1,16 +1,9 @@
<?php
$phpPhraseSettingsFile = $argv[1];
<<<<<<< HEAD
$jsonPhraseSettingsFile = dirname($phpPhraseSettingsFile).'/'.basename($phpPhraseSettingsFile, '.php').'.json';
if (file_exists($phpPhraseSettingsFile) && !file_exists($jsonPhraseSettingsFile)) {
=======
$jsonPhraseSettingsFile = dirname($phpPhraseSettingsFile)."/".basename($phpPhraseSettingsFile, ".php").".json";
if(file_exists($phpPhraseSettingsFile) && !file_exists($jsonPhraseSettingsFile))
{
>>>>>>> 3d939458... Changed phrase_settings.py to phrase-settings.json and added migration function for old php settings file.
include $phpPhraseSettingsFile;
$data = array();
@ -23,8 +16,4 @@ if(file_exists($phpPhraseSettingsFile) && !file_exists($jsonPhraseSettingsFile))
$jsonFile = fopen($jsonPhraseSettingsFile, 'w');
fwrite($jsonFile, json_encode($data));
fclose($jsonFile);
<<<<<<< HEAD
}
=======
}
>>>>>>> 3d939458... Changed phrase_settings.py to phrase-settings.json and added migration function for old php settings file.
}

View File

@ -118,7 +118,7 @@ $$
LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION getorcreate_amenity(lookup_word TEXT,
CREATE OR REPLACE FUNCTION getorcreate_amenity(lookup_word TEXT, normalized_word TEXT,
lookup_class text, lookup_type text)
RETURNS INTEGER
AS $$
@ -128,12 +128,12 @@ DECLARE
BEGIN
lookup_token := ' '||trim(lookup_word);
SELECT min(word_id) FROM word
WHERE word_token = lookup_token and word = lookup_word
WHERE word_token = lookup_token and word = normalized_word
and class = lookup_class and type = lookup_type
INTO return_word_id;
IF return_word_id IS NULL THEN
return_word_id := nextval('seq_word');
INSERT INTO word VALUES (return_word_id, lookup_token, lookup_word,
INSERT INTO word VALUES (return_word_id, lookup_token, normalized_word,
lookup_class, lookup_type, null, 0);
END IF;
RETURN return_word_id;
@ -143,6 +143,7 @@ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION getorcreate_amenityoperator(lookup_word TEXT,
normalized_word TEXT,
lookup_class text,
lookup_type text,
op text)
@ -154,12 +155,12 @@ DECLARE
BEGIN
lookup_token := ' '||trim(lookup_word);
SELECT min(word_id) FROM word
WHERE word_token = lookup_token and word = lookup_word
WHERE word_token = lookup_token and word = normalized_word
and class = lookup_class and type = lookup_type and operator = op
INTO return_word_id;
IF return_word_id IS NULL THEN
return_word_id := nextval('seq_word');
INSERT INTO word VALUES (return_word_id, lookup_token, lookup_word,
INSERT INTO word VALUES (return_word_id, lookup_token, normalized_word,
lookup_class, lookup_type, null, 0, op);
END IF;
RETURN return_word_id;

View File

@ -8,6 +8,7 @@ import subprocess
import sys
import json
from os.path import isfile
from icu import Transliterator # pylint: disable-msg=no-name-in-module
from psycopg2.sql import Identifier, Literal, SQL
from nominatim.tools.exec_utils import get_url
@ -27,10 +28,15 @@ def import_from_wiki(args, db_connection, languages=None):
)
sanity_check_pattern = re.compile(r'^\w+$')
#Get all languages to process.
languages = _get_languages(args.config) if not languages else languages
#array for pairs of class/type
pairs = dict()
transliterator = Transliterator.createFromRules("special-phrases normalizer",
args.config.TERM_NORMALIZATION)
for lang in languages:
LOG.warning('Import phrases for lang: %s', lang)
wiki_page_xml_content = _get_wiki_content(lang)
@ -39,6 +45,7 @@ def import_from_wiki(args, db_connection, languages=None):
for match in matches:
phrase_label = match[0].strip()
normalized_label = transliterator.transliterate(phrase_label)
phrase_class = match[1].strip()
phrase_type = match[2].strip()
phrase_operator = match[3].strip()
@ -59,7 +66,8 @@ def import_from_wiki(args, db_connection, languages=None):
pairs[f'{phrase_class}|{phrase_type}'] = (phrase_class, phrase_type)
_process_amenity(
db_connection, phrase_label, phrase_class, phrase_type, phrase_operator
db_connection, phrase_label, normalized_label,
phrase_class, phrase_type, phrase_operator
)
_create_place_classtype_table_and_indexes(db_connection, args.config, pairs)
@ -118,23 +126,25 @@ def _check_sanity(lang, phrase_class, phrase_type, pattern):
raise
def _process_amenity(db_connection, phrase_label, phrase_class, phrase_type, phrase_operator):
def _process_amenity(db_connection, phrase_label, normalized_label,
phrase_class, phrase_type, phrase_operator):
# pylint: disable-msg=too-many-arguments
"""
Add phrase lookup and corresponding class and type to the word table based on the operator.
"""
with db_connection.cursor() as db_cursor:
if phrase_operator == 'near':
db_cursor.execute("""SELECT getorcreate_amenityoperator(
make_standard_name(%s), %s, %s, 'near')""",
(phrase_label, phrase_class, phrase_type))
make_standard_name(%s), %s, %s, %s, 'near')""",
(phrase_label, normalized_label, phrase_class, phrase_type))
elif phrase_operator == 'in':
db_cursor.execute("""SELECT getorcreate_amenityoperator(
make_standard_name(%s), %s, %s, 'in')""",
(phrase_label, phrase_class, phrase_type))
make_standard_name(%s), %s, %s, %s, 'in')""",
(phrase_label, normalized_label, phrase_class, phrase_type))
else:
db_cursor.execute("""SELECT getorcreate_amenity(
make_standard_name(%s), %s, %s)""",
(phrase_label, phrase_class, phrase_type))
make_standard_name(%s), %s, %s, %s)""",
(phrase_label, normalized_label, phrase_class, phrase_type))
def _create_place_classtype_table_and_indexes(db_connection, config, pairs):

View File

@ -7,39 +7,48 @@ from nominatim.tools.special_phrases import _create_place_classtype_indexes, _cr
def test_get_wiki_content():
assert _get_wiki_content('fr')
def execute_and_verify_add_word(temp_db_conn, phrase_label, phrase_class, phrase_type):
_process_amenity(temp_db_conn, phrase_label, phrase_class, phrase_type, '')
def execute_and_verify_add_word(temp_db_conn, phrase_label, normalized_label,
phrase_class, phrase_type):
_process_amenity(temp_db_conn, phrase_label, normalized_label,
phrase_class, phrase_type, '')
with temp_db_conn.cursor() as temp_db_cursor:
temp_db_cursor.execute(f"""
SELECT * FROM word
WHERE word_token=' {phrase_label}'
AND word='{phrase_label}'
WHERE word_token=' {normalized_label}'
AND word='{normalized_label}'
AND class='{phrase_class}'
AND type='{phrase_type}'
AND type='{phrase_type}'""")
return temp_db_cursor.fetchone()
def execute_and_verify_add_word_with_operator(temp_db_conn, phrase_label, phrase_class, phrase_type, phrase_operator):
_process_amenity(temp_db_conn, phrase_label, phrase_class, phrase_type, phrase_operator)
def execute_and_verify_add_word_with_operator(temp_db_conn, phrase_label, normalized_label,
phrase_class, phrase_type, phrase_operator):
_process_amenity(temp_db_conn, phrase_label, normalized_label,
phrase_class, phrase_type, phrase_operator)
with temp_db_conn.cursor() as temp_db_cursor:
temp_db_cursor.execute(f"""
SELECT * FROM word
WHERE word_token=' {phrase_label}'
AND word='{phrase_label}'
WHERE word_token=' {normalized_label}'
AND word='{normalized_label}'
AND class='{phrase_class}'
AND type='{phrase_type}'
AND operator='{phrase_operator}'""")
return temp_db_cursor.fetchone()
def test_process_amenity_with_near_operator(temp_db_conn, word_table, amenity_operator_funcs):
phrase_label = 'label'
phrase_label = ' label '
normalized_label = 'label'
phrase_class = 'class'
phrase_type = 'type'
assert execute_and_verify_add_word(temp_db_conn, phrase_label, phrase_class, phrase_type)
assert execute_and_verify_add_word_with_operator(temp_db_conn, phrase_label, phrase_class, phrase_type, 'near')
assert execute_and_verify_add_word_with_operator(temp_db_conn, phrase_label, phrase_class, phrase_type, 'in')
assert execute_and_verify_add_word(temp_db_conn, phrase_label, normalized_label,
phrase_class, phrase_type)
assert execute_and_verify_add_word_with_operator(temp_db_conn, phrase_label, normalized_label,
phrase_class, phrase_type, 'near')
assert execute_and_verify_add_word_with_operator(temp_db_conn, phrase_label, normalized_label,
phrase_class, phrase_type, 'in')
def index_exists(db_connect, index):
""" Check that an index with the given name exists in the database.
@ -108,14 +117,14 @@ def amenity_operator_funcs(temp_db_cursor):
DECLARE
o TEXT;
BEGIN
RETURN name; --Basically return the same name for the tests
RETURN trim(name); --Basically return only the trimed name for the tests
END;
$$
LANGUAGE plpgsql IMMUTABLE;
CREATE SEQUENCE seq_word start 1;
CREATE OR REPLACE FUNCTION getorcreate_amenity(lookup_word TEXT,
CREATE OR REPLACE FUNCTION getorcreate_amenity(lookup_word TEXT, normalized_word TEXT,
lookup_class text, lookup_type text)
RETURNS INTEGER
AS $$
@ -125,23 +134,24 @@ def amenity_operator_funcs(temp_db_cursor):
BEGIN
lookup_token := ' '||trim(lookup_word);
SELECT min(word_id) FROM word
WHERE word_token = lookup_token and word = lookup_word
WHERE word_token = lookup_token and word = normalized_word
and class = lookup_class and type = lookup_type
INTO return_word_id;
IF return_word_id IS NULL THEN
return_word_id := nextval('seq_word');
INSERT INTO word VALUES (return_word_id, lookup_token, lookup_word,
INSERT INTO word VALUES (return_word_id, lookup_token, normalized_word,
lookup_class, lookup_type, null, 0);
END IF;
RETURN return_word_id;
END;
$$
LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION getorcreate_amenityoperator(lookup_word TEXT,
lookup_class text,
lookup_type text,
op text)
normalized_word TEXT,
lookup_class text,
lookup_type text,
op text)
RETURNS INTEGER
AS $$
DECLARE
@ -150,12 +160,12 @@ def amenity_operator_funcs(temp_db_cursor):
BEGIN
lookup_token := ' '||trim(lookup_word);
SELECT min(word_id) FROM word
WHERE word_token = lookup_token and word = lookup_word
WHERE word_token = lookup_token and word = normalized_word
and class = lookup_class and type = lookup_type and operator = op
INTO return_word_id;
IF return_word_id IS NULL THEN
return_word_id := nextval('seq_word');
INSERT INTO word VALUES (return_word_id, lookup_token, lookup_word,
INSERT INTO word VALUES (return_word_id, lookup_token, normalized_word,
lookup_class, lookup_type, null, 0, op);
END IF;
RETURN return_word_id;

View File

@ -1,120 +1,120 @@
SELECT getorcreate_amenity(make_standard_name('Aerodrome'), 'aeroway', 'aerodrome');
SELECT getorcreate_amenity(make_standard_name('Aerodromes'), 'aeroway', 'aerodrome');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodrome in'), 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodromes in'), 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodrome near'), 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodromes near'), 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenity(make_standard_name('Airport'), 'aeroway', 'aerodrome');
SELECT getorcreate_amenity(make_standard_name('Airports'), 'aeroway', 'aerodrome');
SELECT getorcreate_amenityoperator(make_standard_name('Airport in'), 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Airports in'), 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Airport near'), 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Airports near'), 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenity(make_standard_name('Bar'), 'amenity', 'bar');
SELECT getorcreate_amenity(make_standard_name('Bars'), 'amenity', 'bar');
SELECT getorcreate_amenityoperator(make_standard_name('Bar in'), 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bars in'), 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bar near'), 'amenity', 'bar', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Bars near'), 'amenity', 'bar', 'near');
SELECT getorcreate_amenity(make_standard_name('Bar'), 'amenity', 'pub');
SELECT getorcreate_amenity(make_standard_name('Bars'), 'amenity', 'pub');
SELECT getorcreate_amenityoperator(make_standard_name('Bar in'), 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bars in'), 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bar near'), 'amenity', 'pub', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Bars near'), 'amenity', 'pub', 'near');
SELECT getorcreate_amenity(make_standard_name('Food'), 'amenity', 'restaurant');
SELECT getorcreate_amenity(make_standard_name('Food'), 'amenity', 'restaurant');
SELECT getorcreate_amenityoperator(make_standard_name('Food in'), 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Food in'), 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Food near'), 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Food near'), 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenity(make_standard_name('Pub'), 'amenity', 'bar');
SELECT getorcreate_amenity(make_standard_name('Pubs'), 'amenity', 'bar');
SELECT getorcreate_amenityoperator(make_standard_name('Pub in'), 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs in'), 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pub near'), 'amenity', 'bar', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs near'), 'amenity', 'bar', 'near');
SELECT getorcreate_amenity(make_standard_name('Pub'), 'amenity', 'pub');
SELECT getorcreate_amenity(make_standard_name('Pubs'), 'amenity', 'pub');
SELECT getorcreate_amenityoperator(make_standard_name('Pub in'), 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs in'), 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pub near'), 'amenity', 'pub', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs near'), 'amenity', 'pub', 'near');
SELECT getorcreate_amenity(make_standard_name('Restaurant'), 'amenity', 'restaurant');
SELECT getorcreate_amenity(make_standard_name('Restaurants'), 'amenity', 'restaurant');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurant in'), 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurants in'), 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurant near'), 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurants near'), 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenity(make_standard_name('Mural'), 'artwork_type', 'mural');
SELECT getorcreate_amenity(make_standard_name('Murals'), 'artwork_type', 'mural');
SELECT getorcreate_amenityoperator(make_standard_name('Mural in'), 'artwork_type', 'mural', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Murals in'), 'artwork_type', 'mural', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Mural near'), 'artwork_type', 'mural', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Murals near'), 'artwork_type', 'mural', 'near');
SELECT getorcreate_amenity(make_standard_name('Sculpture'), 'artwork_type', 'sculpture');
SELECT getorcreate_amenity(make_standard_name('Sculptures'), 'artwork_type', 'sculpture');
SELECT getorcreate_amenityoperator(make_standard_name('Sculpture in'), 'artwork_type', 'sculpture', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Sculptures in'), 'artwork_type', 'sculpture', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Sculpture near'), 'artwork_type', 'sculpture', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Sculptures near'), 'artwork_type', 'sculpture', 'near');
SELECT getorcreate_amenity(make_standard_name('Statue'), 'artwork_type', 'statue');
SELECT getorcreate_amenity(make_standard_name('Statues'), 'artwork_type', 'statue');
SELECT getorcreate_amenityoperator(make_standard_name('Statue in'), 'artwork_type', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statues in'), 'artwork_type', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statue near'), 'artwork_type', 'statue', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Statues near'), 'artwork_type', 'statue', 'near');
SELECT getorcreate_amenity(make_standard_name('ATM'), 'atm', 'yes');
SELECT getorcreate_amenity(make_standard_name('ATMs'), 'atm', 'yes');
SELECT getorcreate_amenityoperator(make_standard_name('ATM in'), 'atm', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('ATMs in'), 'atm', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('ATM near'), 'atm', 'yes', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('ATMs near'), 'atm', 'yes', 'near');
SELECT getorcreate_amenity(make_standard_name('National Park'), 'boundary', 'national_park');
SELECT getorcreate_amenity(make_standard_name('National Parks'), 'boundary', 'national_park');
SELECT getorcreate_amenityoperator(make_standard_name('National Park in'), 'boundary', 'national_park', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('National Parks in'), 'boundary', 'national_park', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('National Park near'), 'boundary', 'national_park', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('National Parks near'), 'boundary', 'national_park', 'near');
SELECT getorcreate_amenity(make_standard_name('Changing table'), 'changing_table', 'yes');
SELECT getorcreate_amenity(make_standard_name('Changing tables'), 'changing_table', 'yes');
SELECT getorcreate_amenityoperator(make_standard_name('Changing table in'), 'changing_table', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Changing tables in'), 'changing_table', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Changing table near'), 'changing_table', 'yes', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Changing tables near'), 'changing_table', 'yes', 'near');
SELECT getorcreate_amenity(make_standard_name('Roundabout'), 'junction', 'roundabout');
SELECT getorcreate_amenity(make_standard_name('Roundabouts'), 'junction', 'roundabout');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabout in'), 'junction', 'roundabout', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabouts in'), 'junction', 'roundabout', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabout near'), 'junction', 'roundabout', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabouts near'), 'junction', 'roundabout', 'near');
SELECT getorcreate_amenity(make_standard_name('Plaque'), 'memorial', 'plaque');
SELECT getorcreate_amenity(make_standard_name('Plaques'), 'memorial', 'plaque');
SELECT getorcreate_amenityoperator(make_standard_name('Plaque in'), 'memorial', 'plaque', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Plaques in'), 'memorial', 'plaque', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Plaque near'), 'memorial', 'plaque', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Plaques near'), 'memorial', 'plaque', 'near');
SELECT getorcreate_amenity(make_standard_name('Statue'), 'memorial', 'statue');
SELECT getorcreate_amenity(make_standard_name('Statues'), 'memorial', 'statue');
SELECT getorcreate_amenityoperator(make_standard_name('Statue in'), 'memorial', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statues in'), 'memorial', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statue near'), 'memorial', 'statue', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Statues near'), 'memorial', 'statue', 'near');
SELECT getorcreate_amenity(make_standard_name('Stolperstein'), 'memorial', 'stolperstein');
SELECT getorcreate_amenity(make_standard_name('Stolpersteins'), 'memorial', 'stolperstein');
SELECT getorcreate_amenity(make_standard_name('Stolpersteine'), 'memorial', 'stolperstein');
SELECT getorcreate_amenityoperator(make_standard_name('Stolperstein in'), 'memorial', 'stolperstein', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteins in'), 'memorial', 'stolperstein', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteine in'), 'memorial', 'stolperstein', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Stolperstein near'), 'memorial', 'stolperstein', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteins near'), 'memorial', 'stolperstein', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteine near'), 'memorial', 'stolperstein', 'near');
SELECT getorcreate_amenity(make_standard_name('War Memorial'), 'memorial', 'war_memorial');
SELECT getorcreate_amenity(make_standard_name('War Memorials'), 'memorial', 'war_memorial');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorial in'), 'memorial', 'war_memorial', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorials in'), 'memorial', 'war_memorial', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorial near'), 'memorial', 'war_memorial', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorials near'), 'memorial', 'war_memorial', 'near');
SELECT getorcreate_amenity(make_standard_name('Aerodrome'), 'aerodrome', 'aeroway', 'aerodrome');
SELECT getorcreate_amenity(make_standard_name('Aerodromes'), 'aerodromes', 'aeroway', 'aerodrome');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodrome in'), 'aerodrome in', 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodromes in'), 'aerodromes in', 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodrome near'), 'aerodrome near', 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Aerodromes near'), 'aerodromes near', 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenity(make_standard_name('Airport'), 'airport', 'aeroway', 'aerodrome');
SELECT getorcreate_amenity(make_standard_name('Airports'), 'airports', 'aeroway', 'aerodrome');
SELECT getorcreate_amenityoperator(make_standard_name('Airport in'), 'airport in', 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Airports in'), 'airports in', 'aeroway', 'aerodrome', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Airport near'), 'airport near', 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Airports near'), 'airports near', 'aeroway', 'aerodrome', 'near');
SELECT getorcreate_amenity(make_standard_name('Bar'), 'bar', 'amenity', 'bar');
SELECT getorcreate_amenity(make_standard_name('Bars'), 'bars', 'amenity', 'bar');
SELECT getorcreate_amenityoperator(make_standard_name('Bar in'), 'bar in', 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bars in'), 'bars in', 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bar near'), 'bar near', 'amenity', 'bar', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Bars near'), 'bars near', 'amenity', 'bar', 'near');
SELECT getorcreate_amenity(make_standard_name('Bar'), 'bar', 'amenity', 'pub');
SELECT getorcreate_amenity(make_standard_name('Bars'), 'bars', 'amenity', 'pub');
SELECT getorcreate_amenityoperator(make_standard_name('Bar in'), 'bar in', 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bars in'), 'bars in', 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Bar near'), 'bar near', 'amenity', 'pub', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Bars near'), 'bars near', 'amenity', 'pub', 'near');
SELECT getorcreate_amenity(make_standard_name('Food'), 'food', 'amenity', 'restaurant');
SELECT getorcreate_amenity(make_standard_name('Food'), 'food', 'amenity', 'restaurant');
SELECT getorcreate_amenityoperator(make_standard_name('Food in'), 'food in', 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Food in'), 'food in', 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Food near'), 'food near', 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Food near'), 'food near', 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenity(make_standard_name('Pub'), 'pub', 'amenity', 'bar');
SELECT getorcreate_amenity(make_standard_name('Pubs'), 'pubs', 'amenity', 'bar');
SELECT getorcreate_amenityoperator(make_standard_name('Pub in'), 'pub in', 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs in'), 'pubs in', 'amenity', 'bar', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pub near'), 'pub near', 'amenity', 'bar', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs near'), 'pubs near', 'amenity', 'bar', 'near');
SELECT getorcreate_amenity(make_standard_name('Pub'), 'pub', 'amenity', 'pub');
SELECT getorcreate_amenity(make_standard_name('Pubs'), 'pubs', 'amenity', 'pub');
SELECT getorcreate_amenityoperator(make_standard_name('Pub in'), 'pub in', 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs in'), 'pubs in', 'amenity', 'pub', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Pub near'), 'pub near', 'amenity', 'pub', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Pubs near'), 'pubs near', 'amenity', 'pub', 'near');
SELECT getorcreate_amenity(make_standard_name('Restaurant'), 'restaurant', 'amenity', 'restaurant');
SELECT getorcreate_amenity(make_standard_name('Restaurants'), 'restaurants', 'amenity', 'restaurant');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurant in'), 'restaurant in', 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurants in'), 'restaurants in', 'amenity', 'restaurant', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurant near'), 'restaurant near', 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Restaurants near'), 'restaurants near', 'amenity', 'restaurant', 'near');
SELECT getorcreate_amenity(make_standard_name('Mural'), 'mural', 'artwork_type', 'mural');
SELECT getorcreate_amenity(make_standard_name('Murals'), 'murals', 'artwork_type', 'mural');
SELECT getorcreate_amenityoperator(make_standard_name('Mural in'), 'mural in', 'artwork_type', 'mural', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Murals in'), 'murals in', 'artwork_type', 'mural', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Mural near'), 'mural near', 'artwork_type', 'mural', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Murals near'), 'murals near', 'artwork_type', 'mural', 'near');
SELECT getorcreate_amenity(make_standard_name('Sculpture'), 'sculpture', 'artwork_type', 'sculpture');
SELECT getorcreate_amenity(make_standard_name('Sculptures'), 'sculptures', 'artwork_type', 'sculpture');
SELECT getorcreate_amenityoperator(make_standard_name('Sculpture in'), 'sculpture in', 'artwork_type', 'sculpture', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Sculptures in'), 'sculptures in', 'artwork_type', 'sculpture', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Sculpture near'), 'sculpture near', 'artwork_type', 'sculpture', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Sculptures near'), 'sculptures near', 'artwork_type', 'sculpture', 'near');
SELECT getorcreate_amenity(make_standard_name('Statue'), 'statue', 'artwork_type', 'statue');
SELECT getorcreate_amenity(make_standard_name('Statues'), 'statues', 'artwork_type', 'statue');
SELECT getorcreate_amenityoperator(make_standard_name('Statue in'), 'statue in', 'artwork_type', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statues in'), 'statues in', 'artwork_type', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statue near'), 'statue near', 'artwork_type', 'statue', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Statues near'), 'statues near', 'artwork_type', 'statue', 'near');
SELECT getorcreate_amenity(make_standard_name('ATM'), 'atm', 'atm', 'yes');
SELECT getorcreate_amenity(make_standard_name('ATMs'), 'atms', 'atm', 'yes');
SELECT getorcreate_amenityoperator(make_standard_name('ATM in'), 'atm in', 'atm', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('ATMs in'), 'atms in', 'atm', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('ATM near'), 'atm near', 'atm', 'yes', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('ATMs near'), 'atms near', 'atm', 'yes', 'near');
SELECT getorcreate_amenity(make_standard_name('National Park'), 'national park', 'boundary', 'national_park');
SELECT getorcreate_amenity(make_standard_name('National Parks'), 'national parks', 'boundary', 'national_park');
SELECT getorcreate_amenityoperator(make_standard_name('National Park in'), 'national park in', 'boundary', 'national_park', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('National Parks in'), 'national parks in', 'boundary', 'national_park', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('National Park near'), 'national park near', 'boundary', 'national_park', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('National Parks near'), 'national parks near', 'boundary', 'national_park', 'near');
SELECT getorcreate_amenity(make_standard_name('Changing table'), 'changing table', 'changing_table', 'yes');
SELECT getorcreate_amenity(make_standard_name('Changing tables'), 'changing tables', 'changing_table', 'yes');
SELECT getorcreate_amenityoperator(make_standard_name('Changing table in'), 'changing table in', 'changing_table', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Changing tables in'), 'changing tables in', 'changing_table', 'yes', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Changing table near'), 'changing table near', 'changing_table', 'yes', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Changing tables near'), 'changing tables near', 'changing_table', 'yes', 'near');
SELECT getorcreate_amenity(make_standard_name('Roundabout'), 'roundabout', 'junction', 'roundabout');
SELECT getorcreate_amenity(make_standard_name('Roundabouts'), 'roundabouts', 'junction', 'roundabout');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabout in'), 'roundabout in', 'junction', 'roundabout', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabouts in'), 'roundabouts in', 'junction', 'roundabout', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabout near'), 'roundabout near', 'junction', 'roundabout', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Roundabouts near'), 'roundabouts near', 'junction', 'roundabout', 'near');
SELECT getorcreate_amenity(make_standard_name('Plaque'), 'plaque', 'memorial', 'plaque');
SELECT getorcreate_amenity(make_standard_name('Plaques'), 'plaques', 'memorial', 'plaque');
SELECT getorcreate_amenityoperator(make_standard_name('Plaque in'), 'plaque in', 'memorial', 'plaque', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Plaques in'), 'plaques in', 'memorial', 'plaque', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Plaque near'), 'plaque near', 'memorial', 'plaque', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Plaques near'), 'plaques near', 'memorial', 'plaque', 'near');
SELECT getorcreate_amenity(make_standard_name('Statue'), 'statue', 'memorial', 'statue');
SELECT getorcreate_amenity(make_standard_name('Statues'), 'statues', 'memorial', 'statue');
SELECT getorcreate_amenityoperator(make_standard_name('Statue in'), 'statue in', 'memorial', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statues in'), 'statues in', 'memorial', 'statue', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Statue near'), 'statue near', 'memorial', 'statue', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Statues near'), 'statues near', 'memorial', 'statue', 'near');
SELECT getorcreate_amenity(make_standard_name('Stolperstein'), 'stolperstein', 'memorial', 'stolperstein');
SELECT getorcreate_amenity(make_standard_name('Stolpersteins'), 'stolpersteins', 'memorial', 'stolperstein');
SELECT getorcreate_amenity(make_standard_name('Stolpersteine'), 'stolpersteine', 'memorial', 'stolperstein');
SELECT getorcreate_amenityoperator(make_standard_name('Stolperstein in'), 'stolperstein in', 'memorial', 'stolperstein', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteins in'), 'stolpersteins in', 'memorial', 'stolperstein', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteine in'), 'stolpersteine in', 'memorial', 'stolperstein', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('Stolperstein near'), 'stolperstein near', 'memorial', 'stolperstein', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteins near'), 'stolpersteins near', 'memorial', 'stolperstein', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('Stolpersteine near'), 'stolpersteine near', 'memorial', 'stolperstein', 'near');
SELECT getorcreate_amenity(make_standard_name('War Memorial'), 'war memorial', 'memorial', 'war_memorial');
SELECT getorcreate_amenity(make_standard_name('War Memorials'), 'war memorials', 'memorial', 'war_memorial');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorial in'), 'war memorial in', 'memorial', 'war_memorial', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorials in'), 'war memorials in', 'memorial', 'war_memorial', 'in');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorial near'), 'war memorial near', 'memorial', 'war_memorial', 'near');
SELECT getorcreate_amenityoperator(make_standard_name('War Memorials near'), 'war memorials near', 'memorial', 'war_memorial', 'near');
CREATE INDEX idx_placex_classtype ON placex (class, type);CREATE TABLE place_classtype_aeroway_aerodrome AS SELECT place_id AS place_id,st_centroid(geometry) AS centroid FROM placex WHERE class = 'aeroway' AND type = 'aerodrome';
CREATE INDEX idx_place_classtype_aeroway_aerodrome_centroid ON place_classtype_aeroway_aerodrome USING GIST (centroid);
CREATE INDEX idx_place_classtype_aeroway_aerodrome_place_id ON place_classtype_aeroway_aerodrome USING btree(place_id);