Span#

class scikitplot.cleanprompt.Span(start, end, kind, text, detector, priority=0, confidence=1.0)[source]#

A half-open [start, end) character interval flagged by one detector.

Parameters:
startint

Inclusive start offset into the original text. Must be >= 0.

endint

Exclusive end offset. Must be > start.

kindstr

Category label used to build the placeholder, for example "EMAIL". Must be non-empty and contain no placeholder delimiter characters.

textstr

The matched surface, exactly as it appears in the original.

detectorstr

Name of the detector that produced this span.

priorityint, default=0

Arbitration weight. Higher wins under PRIORITY_WINS.

confidencefloat, default=1.0

Detector-reported confidence in [0.0, 1.0]. Carried for reporting and filtering; it never silently drops a span.

Raises:
ValueError

If the interval is empty or negative, if kind is empty, or if confidence is outside [0.0, 1.0].

Parameters:

Notes

Developer notes. The field order gives a meaningful order=True: spans sort by start, then by end. Resolution relies on that natural order and then applies its own tie-breaks, so sorting is stable and reproducible across processes regardless of hash randomisation.

Examples

>>> Span(0, 5, "EMAIL", "a@b.c", "email").length
5
confidence: float = 1.0#
detector: str[source]#
end: int[source]#
kind: str[source]#
property length: int#

Number of characters covered by this span.

Type:

int

overlaps(other)[source]#

Return whether this span shares at least one character with other.

Parameters:
otherSpan

The span to test against.

Returns:
bool

True when the half-open intervals intersect.

Parameters:

other (Span)

Return type:

bool

priority: int = 0#
start: int[source]#
text: str[source]#