forked from hans/Nominatim
generalize normalization step for search query
It is now possible to configure functions for changing the query input before it is analysed by the tokenizer. Code is a cleaned-up version of the implementation by @miku.
This commit is contained in:
32
src/nominatim_api/query_preprocessing/base.py
Normal file
32
src/nominatim_api/query_preprocessing/base.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Common data types and protocols for preprocessing.
|
||||
"""
|
||||
from typing import List, Callable
|
||||
|
||||
from ..typing import Protocol
|
||||
from ..search import query as qmod
|
||||
from .config import QueryConfig
|
||||
|
||||
QueryProcessingFunc = Callable[[List[qmod.Phrase]], List[qmod.Phrase]]
|
||||
|
||||
|
||||
class QueryHandler(Protocol):
|
||||
""" Protocol for query modules.
|
||||
"""
|
||||
def create(self, config: QueryConfig) -> QueryProcessingFunc:
|
||||
"""
|
||||
Create a function for sanitizing a place.
|
||||
Arguments:
|
||||
config: A dictionary with the additional configuration options
|
||||
specified in the tokenizer configuration
|
||||
normalizer: A instance to transliterate text
|
||||
Return:
|
||||
The result is a list modified by the preprocessor.
|
||||
"""
|
||||
pass
|
||||
Reference in New Issue
Block a user