Lexicon¶
burmesenlp.lexicon.Lexicon ¶
Word -> POS-tags mapping with syllable-aware longest-match support.
Source code in src/burmesenlp/lexicon/__init__.py
max_word_syllables
property
¶
Syllable count of the longest word (bounds longest-match search).
default
classmethod
¶
Build the built-in lexicon: closed-class seed + bundled JSON files.
Every lexicon/data/*.json file is merged (sorted by filename) onto
the in-code seed / grammar lists so function words keep preferred
multi-tag sets when both sources list a word. Additional files in
that directory are picked up automatically.
Source code in src/burmesenlp/lexicon/__init__.py
from_file
classmethod
¶
Load a lexicon from .json or .txt.
With merge_default=True (used by :class:BurmeseNLP), entries are
merged on top of :meth:default with per-word tag union.
With merge_default=False, only the file contents are loaded.
Raises LexiconError on unreadable files, bad format, or schema
violations -- never falls back silently.
Source code in src/burmesenlp/lexicon/__init__.py
from_json
classmethod
¶
Load a lexicon from canonical JSON: {"word": ["tag", ...], ...}.
See :meth:from_file for merge_default semantics.
Source code in src/burmesenlp/lexicon/__init__.py
from_txt
classmethod
¶
Load a lexicon from a line-based import file: word\ttag1,tag2.
This is a convenience import format; :meth:save always writes JSON.
See :meth:from_file for merge_default semantics.
Source code in src/burmesenlp/lexicon/__init__.py
add ¶
merge ¶
Union entries into this lexicon word-by-word (O(n) inserts).
save ¶
Atomically save the lexicon as UTF-8 JSON (canonical format).
Source code in src/burmesenlp/lexicon/__init__.py
tags ¶
burmesenlp.lexicon.LexiconError ¶
Bases: ValueError
Raised when a lexicon file or entry is invalid.
burmesenlp.lexicon.POS_TAGS
module-attribute
¶
POS_TAGS: Dict[str, str] = {'NOUN': 'noun', 'VERB': 'verb', 'ADJ': 'adjective', 'ADV': 'adverb', 'PRON': 'pronoun', 'NUM': 'number (digits or text)', 'CONJ': 'conjunction', 'INTJ': 'interjection', 'PUNCT': 'punctuation', 'POSTP': 'postposition / case marker', 'PART': 'particle', 'AUX': 'auxiliary', 'SFP': 'sentence-final particle', 'ABB': 'abbreviation', 'FW': 'foreign word', 'SB': 'symbol', 'IDIOM': 'multi-word idiom / fixed expression (BMWE)', 'UNK': 'unknown'}