MultilangChunkMeta#
- class scikitplot.corpus.MultilangChunkMeta(script=None, script_direction=None, is_mixed_script=None, chunking_unit=None, grapheme_count=None, codepoint_count=None, semantemes=None, semanteme_count=None, morphemes=None, script_spans=None, script_model_version=None, preprocessing_trace=None, raw_text=None, embedding=None, language_hint=None, model_name=None, chunking_duration_ms=None, preprocessing_duration_ms=None, layer2_strategy=None, pipeline_id=None, created_at_utc=None, char_offset_start=None, char_offset_end=None, token_count=None, stopword_count=None, unique_token_count=None, char_count=None, avg_token_length=None, is_rtl=None)[source]#
Per-chunk multilang analysis bundle — stored in
chunk.metadata.Collects all Layer 0-3 artefacts for a single chunk in one place so downstream consumers have a uniform access pattern regardless of which chunker produced the chunk.
- Parameters:
- scriptstr or None
Dominant
ScriptTypevalue string for this chunk.- script_directionstr or None
Writing direction:
"ltr","rtl","ttb".- is_mixed_scriptbool or None
Trueif the chunk contains codepoints from more than one script.- chunking_unitstr or None
Granularity:
"word","sentence","paragraph","fixed_window","grapheme_cluster","semanteme".- grapheme_countint or None
UAX #29 grapheme cluster count for
chunk.text.- codepoint_countint or None
len(chunk.text)— stored explicitly for comparison.- semantemeslist[SemantemeInfo] or None
Per-semanteme analysis list.
Nonewhen semantic analysis was not applied.- semanteme_countint or None
len(semantemes)pre-computed for fast access.- morphemeslist[str] or None
Flat morpheme surface list (deduplicated from
semantemes).- script_spanslist[dict] or None
ScriptSpandicts for mixed-script chunks.- script_model_versionstr or None
Embedding model version used, format
"name@version".- preprocessing_tracePreprocessingTrace or None
Full audit trail of preprocessing steps.
Nonewheninclude_preprocessing_trace=False.- raw_textstr or None
Original pre-processing text for this chunk’s span.
Nonewheninclude_raw_text=False.- embeddinglist[float] or None
Dense chunk-level embedding vector.
Noneuntil an embedder is applied. Usewith_embeddingto attach one.- language_hintstr or None
ISO 639-1 / BCP-47 detected language code.
- model_namestr or None
Name of the embedding model (e.g.
"paraphrase-multilingual-mpnet-base-v2").
- Parameters:
script (str | None)
script_direction (str | None)
is_mixed_script (bool | None)
chunking_unit (str | None)
grapheme_count (int | None)
codepoint_count (int | None)
semantemes (list[SemantemeInfo] | None)
semanteme_count (int | None)
script_model_version (str | None)
preprocessing_trace (PreprocessingTrace | None)
raw_text (str | None)
language_hint (str | None)
model_name (str | None)
chunking_duration_ms (float | None)
preprocessing_duration_ms (float | None)
layer2_strategy (str | None)
pipeline_id (str | None)
created_at_utc (str | None)
char_offset_start (int | None)
char_offset_end (int | None)
token_count (int | None)
stopword_count (int | None)
unique_token_count (int | None)
char_count (int | None)
avg_token_length (float | None)
is_rtl (bool | None)
Notes
User note: Access via
chunk.metadata.get("multilang")— it is stored as a dict (viato_dict). If you need to attach an embedding later, callwith_embeddingwhich returns a new frozen instance without mutating the original.Developer note: All chunkers populate this via
_build_multilang_meta. The mixin’s_build_multilang_metais the single authority for constructing these objects — do not construct them inline in chunker code.- char_offset_start: int | None = None#
Start character offset of this chunk in the raw (pre-NFC) text. Allows exact re-location of the original source span for comparison.
- chunking_duration_ms: float | None = None#
Wall-clock time in milliseconds to produce this chunk. Populated by the chunker’s
MultilangMixin._ml_build_meta.
- created_at_utc: str | None = None#
ISO-8601 UTC timestamp of when this chunk was produced, format
YYYY-MM-DDTHH:MM:SS.ffffffZ.Nonewhen not tracked.
- is_rtl: bool | None = None#
Truewhenscript_direction == "rtl"; precomputed for fast dataframe filtering.
- layer2_strategy: str | None = None#
Name of the Layer 2
SegmentationStrategyclass that produced this chunk (e.g."JapaneseStrategy","ArabicMorphologicalStrategy","GraphemeClusterStrategy").
- pipeline_id: str | None = None#
Optional pipeline run identifier injected by the caller for correlation across large batch runs.
- preprocessing_duration_ms: float | None = None#
Wall-clock time in milliseconds for all preprocessing steps combined (BOM strip + control strip + NFC normalisation).
- preprocessing_trace: PreprocessingTrace | None = None#
- semantemes: list[SemantemeInfo] | None = None#
- stopword_count: int | None = None#
Number of stopwords among the tokens (if stopword analysis was run).
- to_dict(*, include_raw_text=False, include_preprocessing_trace=False, include_embedding=False, include_semanteme_detail=True)[source]#
Serialise to a JSON-safe dict for
chunk.metadata["multilang"].- Parameters:
- include_raw_textbool
Include
raw_textin output. DefaultFalse.- include_preprocessing_tracebool
Include the full preprocessing trace. Default
False.- include_embeddingbool
Include the dense embedding vector. Default
False.- include_semanteme_detailbool
Include full
semantemeslist. DefaultTrue. Set toFalseto include onlysemanteme_count.
- Returns:
- MetadataDict
All non-None fields populated per the flag settings.
- Parameters:
- Return type:
- with_embedding(vector, *, model_name=None, model_version=None)[source]#
Return a copy with an embedding vector and optional model metadata.
- Parameters:
- vectorlist[float]
Dense embedding produced by any encoder.
- model_namestr, optional
Name of the model used (e.g.
"paraphrase-multilingual-mpnet-base-v2").- model_versionstr, optional
Model version string (e.g.
"1.2.0").
- Returns:
- MultilangChunkMeta
New frozen instance.
- Parameters:
- Return type:
Notes
CRITICAL-04 fix: uses
dataclasses.replaceso all fields not explicitly named here are propagated automatically. Any new fields added toMultilangChunkMetawill never be silently dropped.