X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/77510f4a3bb7a40c85d27ed5c71b20ef79a3aa83..e37cfc64d2734bf67aedf44e57585d6bd5ff06af:/nominatim/tokenizer/base.py diff --git a/nominatim/tokenizer/base.py b/nominatim/tokenizer/base.py index 5a3d3b12..6484ff6a 100644 --- a/nominatim/tokenizer/base.py +++ b/nominatim/tokenizer/base.py @@ -10,12 +10,13 @@ mainly for documentation purposes. """ from abc import ABC, abstractmethod from typing import List, Tuple, Dict, Any +from pathlib import Path + +from typing_extensions import Protocol from nominatim.config import Configuration from nominatim.data.place_info import PlaceInfo -# pylint: disable=unnecessary-pass - class AbstractAnalyzer(ABC): """ The analyzer provides the functions for analysing names and building the token database. @@ -230,3 +231,13 @@ class AbstractTokenizer(ABC): When used outside the with construct, the caller must ensure to call the close() function before destructing the analyzer. """ + + +class TokenizerModule(Protocol): + """ Interface that must be exported by modules that implement their + own tokenizer. + """ + + def create(self, dsn: str, data_dir: Path) -> AbstractTokenizer: + """ Factory for new tokenizers. + """