ScriptSpan#

class scikitplot.corpus.ScriptSpan(text, script, direction, start, end)[source]#

A contiguous span of text in a single Unicode script.

Produced by ScriptSegmenter from NFC-normalised text. The index fields are character (codepoint) offsets into the segmented text.

Parameters:
textstr

The span text (NFC normalised).

scriptScriptType

Detected script for this span.

directionstr

Writing direction: "ltr" | "rtl" | "ttb".

startint

Character offset of the span in the segmented text (inclusive).

endint

Character offset of the span in the segmented text (exclusive); text == segmented_text[start:end].

Parameters:

Notes

Developer note: The offsets are character (codepoint) offsets, the unit every Chunk built from a span uses. They used to be documented as grapheme-cluster indices, which no consumer used as such: a span after an emoji or a combining mark pointed at the wrong characters. A span never splits a grapheme cluster.

Examples

>>> span = ScriptSpan(
...     text="Hello", script=ScriptType.LATIN, direction="ltr", start=0, end=5
... )
>>> span.script
<ScriptType.LATIN: 'latin'>
direction: str[source]#
end: int[source]#
script: ScriptType[source]#
start: int[source]#
text: str[source]#