Coverage for geoparser/modules/recognizers/base.py: 100%
7 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-20 18:08 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-20 18:08 +0000
1import typing as t
2from abc import abstractmethod
4from geoparser.modules.module import Module
7class Recognizer(Module):
8 """
9 Abstract class for modules that perform reference recognition.
11 These modules identify potential references (place names) in text.
12 They are completely database-agnostic and operate only on raw text data.
13 """
15 # This base class should have NAME set to None since it should not be instantiated directly
16 NAME = None
18 def __init__(self, **kwargs):
19 """
20 Initialize a recognition module.
22 Args:
23 **kwargs: Configuration parameters for this module
24 """
25 super().__init__(**kwargs)
27 @abstractmethod
28 def predict(
29 self, texts: t.List[str]
30 ) -> t.List[t.Union[t.List[t.Tuple[int, int]], None]]:
31 """
32 Predict references in multiple document texts.
34 This abstract method must be implemented by child classes.
36 Args:
37 texts: List of document text strings to process
39 Returns:
40 A list where each element corresponds to one document at the same index in the
41 input list. Each element is either a list of (start, end) tuples containing
42 positions of references found in the document, or None to indicate that
43 predictions are not available for that document (e.g., unsupported language,
44 missing data, etc.).
45 """