DetectorRegistry#
- class scikitplot.cleanprompt.DetectorRegistry(detectors=None)[source]#
An ordered, immutable-by-convention collection of detectors.
- Parameters:
- detectorsiterable of Detector, optional
Initial detectors.
- Raises:
- PolicyError
If two detectors share a name.
- Parameters:
detectors (Iterable[Detector] | None)
Notes
Developer notes.
addreturnsselffor chaining but mutates, so a registry is a builder, not a value. The engine never mutates one; it reads the registry once per pass. Names must be unique because arbitration uses the detector name as its final, deterministic tie-break — two detectors sharing a name would make the outcome depend on insertion order.- add(detector)[source]#
Append a detector.
- Parameters:
- detectorDetector
The detector to add.
- Returns:
- DetectorRegistry
This registry, for chaining.
- Raises:
- PolicyError
If a detector of the same name is already registered.
- Parameters:
detector (Detector)
- Return type:
- detect_all(text, policy, detectors=None)[source]#
Run detectors and collect every span.
- Parameters:
- textstr
The original text.
- policyRedactionPolicy
The active policy; supplies
Limits.max_spansandRedactionPolicy.min_confidence.- detectorssequence of Detector, optional
Override the registry’s own detectors.
- Returns:
- list of Span
Unresolved spans, which may overlap.
- Raises:
- DetectorError
If a detector raises. The detector name is carried on the error.
- LimitExceededError
If more than
Limits.max_spansspans are produced.
- Parameters:
text (str)
policy (RedactionPolicy)
- Return type:
list[Span]
Notes
Developer notes. The span cap is checked while collecting, not afterwards, so a pathological detector cannot exhaust memory before the bound is noticed.