Gazetteer¶
burmesenlp.gazetteer.GazetteerManager ¶
GazetteerManager(lexicon: Optional[Lexicon] = None, *, autoload: bool = True, root: Optional[Path] = None)
Load gazetteer JSON files and provide contains / lookup / match APIs.
Used by BurmeseNLP.process() (after POS) to fill Document.entities.
First full load tokenizes every surface (including large village lists)
and may take noticeable time; pass gazetteer=False to skip.
Source code in src/burmesenlp/gazetteer/manager.py
load ¶
Load a gazetteer directory or a single JSON file. Returns entries added.
Source code in src/burmesenlp/gazetteer/manager.py
longest_match ¶
Longest trie hit starting at start, or None.
Source code in src/burmesenlp/gazetteer/manager.py
find_all ¶
Greedy left-to-right longest matches over tokens.
PERSON hits absorb a preceding honorific token when present
(ဦး / ဒေါ် / …). Also matches a single token that fuses
honorific + name (ဒေါ်အောင်ဆန်းစုကြည်).
Short geographic hits (1–2 syllables) are rejected unless a locative
cue is nearby, or — for 2-syllable names — the span's POS looks
nominal. Pass post-BMWE pos_tags aligned with tokens.
Source code in src/burmesenlp/gazetteer/manager.py
burmesenlp.gazetteer.EntityType ¶
Bases: Enum
burmesenlp.gazetteer.GazetteerHit
dataclass
¶
GazetteerHit(text: str, tokens: Tuple[str, ...], entity_type: EntityType, start: int = 0, end: int = 0, attributes: Dict[str, object] = dict())
A matched gazetteer surface form over a token sequence.