add type annotations to ICU tokenizer helper modules

This commit is contained in:
Sarah Hoffmann
2022-07-13 22:55:40 +02:00
parent 77510f4a3b
commit e37cfc64d2
5 changed files with 73 additions and 34 deletions

View File

@@ -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.
"""