PreprocessingStep#
- class scikitplot.corpus.PreprocessingStep(name, description, changed, char_delta, grapheme_delta=None, params=None, input_hash=None, output_hash=None, duration_s=None)[source]#
Record of a single preprocessing transformation applied to raw text.
Used to build a
PreprocessingTracethat makes the preprocessing pipeline fully retrospective — every change is documented with enough information to verify, replay, or invert it.- Parameters:
- namestr
Short identifier of the transformation (e.g.
"nfc_normalise","strip_control","bom_strip","whitespace_collapse","ocr_correction").- descriptionstr
Human-readable explanation of what this step does.
- changedbool
Trueif this step actually modified the text.Falsewhen the text was already in the expected form (idempotent execution).- char_deltaint
Change in codepoint count:
len(after) - len(before). Negative for stripping steps; zero for reordering steps.- grapheme_deltaint or None
Change in grapheme cluster count.
Noneif grapheme counting was not available at this step (regexnot installed).- paramsMetadataDict or None
Configuration parameters used for this step. Must be JSON-serialisable.
Noneif the step has no parameters.- input_hashstr or None
MD5 hex of the text before this step. Allows exact change detection without storing the full text.
Noneif not tracked.- output_hashstr or None
MD5 hex of the text after this step.
- Parameters:
Notes
Developer note: Hash all PreprocessingStep objects into a stable fingerprint to build a preprocessing fingerprint for idempotency verification on pipeline re-runs. The fingerprint is:
hashlib.md5(",".join(s.name for s in trace.steps).encode()).hexdigest()