Pipeline¶
burmesenlp.pipeline.BurmeseNLP ¶
BurmeseNLP(dictionary_path: Optional[str] = None, *, lexicon: Optional[Lexicon] = None, split_on_final_particles: bool = True, gazetteer: bool = True, gazetteer_manager: Optional[GazetteerManager] = None)
Myanmar (Burmese) NLP preprocessing pipeline.
All character positions returned by this class refer to the
normalized form of the input (zero-width characters stripped, NFC
applied); normalize() is exposed so callers can reproduce it.
Zawgyi is not auto-converted: call zg2uni / to_unicode before
process when the encoding is Zawgyi or unknown.
Loading a dictionary that does not exist or is malformed raises
LexiconError instead of silently falling back. Custom files
(.json or .txt) are merged on top of the bundled default
lexicon with per-word tag union; pass lexicon=... for full control.
Source code in src/burmesenlp/pipeline/__init__.py
syllable_segment ¶
syllable_tokens ¶
word_segment ¶
word_tokens ¶
sentence_segment ¶
Segment text into sentences (grammar-aware: POS + chunks).
Source code in src/burmesenlp/pipeline/__init__.py
sentence_segment_with_positions ¶
Sentences with (start, end) offsets into the normalized text.
Guaranteed: normalize(text)[start:end] == sentence.
Source code in src/burmesenlp/pipeline/__init__.py
pos_tag ¶
Tag an already-segmented word list (optionally MWE-aware).
Source code in src/burmesenlp/pipeline/__init__.py
chunk_from_tokens ¶
Chunk from words + POS tags (does not re-tag).
chunk ¶
Segment, MWE-merge, POS-tag, then chunk text.
Source code in src/burmesenlp/pipeline/__init__.py
load_mwe ¶
Load an additional MWE resource (JSON/TXT) into the engine.
Source code in src/burmesenlp/pipeline/__init__.py
process ¶
Run the full pipeline once, with all outputs mutually consistent.
Flow: normalize → syllables → words → BMWE → POS → gazetteer NER → phrase chunk (entity spans locked as NP) → sentences → ClauseParser.
doc.entities is the semantic gazetteer layer; matching spans also
appear as NP chunks with features["entity"]. Pass gazetteer=False
to skip NER.
Source code in src/burmesenlp/pipeline/__init__.py
add_to_dictionary ¶
save_dictionary ¶
get_stats ¶
Basic statistics about the text.
Source code in src/burmesenlp/pipeline/__init__.py
extract_features_for_crf ¶
Per-syllable feature dicts for training CRF / BiLSTM-CRF models.
Source code in src/burmesenlp/pipeline/__init__.py
burmesenlp.pipeline.process ¶
One-shot pipeline: normalize → words → MWE → POS → gazetteer → phrases → sentences → clauses.
Does not auto-convert Zawgyi; use zg2uni / to_unicode first if needed.
Source code in src/burmesenlp/pipeline/__init__.py
burmesenlp.pipeline.document.Document
dataclass
¶
Document(raw_text: str, syllables: List[str], words: List[str], sentences: List[str], pos_tags: List[Tuple[str, str]], sentence_word_tags: List[List[Tuple[str, str]]], chunks: List[Chunk] = list(), mwe: List[MWEToken] = list(), entities: List[GazetteerHit] = list(), sentence_trees: List[SyntaxSentence] = list())
Full-pipeline output with attribute and mapping access.
Layers stay separate::
entities — semantic gazetteer NER (PERSON / TOWN / …)
chunks — syntactic phrases (NP / VP / PP / …)
sentence_trees / clauses — clause syntax
For json.dump, use doc.to_dict().
clauses
property
¶
Flat list of clauses from sentence_trees (syntactic layer).
to_dict ¶
Plain dict suitable for json.dump / json.dumps.