forked from hans/Nominatim
clean_housenumbers: make kinds and delimiters configurable
Also adds unit tests for various options.
This commit is contained in:
@@ -9,21 +9,16 @@ Sanitizer that splits lists of names into their components.
|
||||
|
||||
Arguments:
|
||||
delimiters: Define the set of characters to be used for
|
||||
splitting the list. (default: `,;`)
|
||||
splitting the list. (default: ',;')
|
||||
"""
|
||||
import re
|
||||
|
||||
from nominatim.errors import UsageError
|
||||
from nominatim.tokenizer.sanitizers.helpers import create_split_regex
|
||||
|
||||
def create(func):
|
||||
""" Create a name processing function that splits name values with
|
||||
multiple values into their components.
|
||||
"""
|
||||
delimiter_set = set(func.get('delimiters', ',;'))
|
||||
if not delimiter_set:
|
||||
raise UsageError("Set of delimiters in split-name-list sanitizer is empty.")
|
||||
|
||||
regexp = re.compile('\\s*[{}]\\s*'.format(''.join('\\' + d for d in delimiter_set)))
|
||||
regexp = create_split_regex(func)
|
||||
|
||||
def _process(obj):
|
||||
if not obj.names:
|
||||
|
||||
Reference in New Issue
Block a user