Integrations¶
Framework adapters. Each module needs its extra (see Install).
hf ¶
Hugging Face datasets adapter (pip install squeakycleantext[datasets]).
SCTMap ¶
SCTMap(
columns: Sequence[str] = ("text",),
output: str = "overwrite",
config: TextCleanerConfig | str | None = None,
score: bool = False,
*,
schema: FieldSchema | None = None,
context: DetectionContext | None = None,
registry_factory: Callable[
[TextCleanerConfig], DetectorRegistry
]
| None = None,
)
Picklable batched map function; pickles only its config, never the cleaner.
clean_dataset ¶
clean_dataset(
ds: Any,
*,
columns: Sequence[str] = ("text",),
output: str = "overwrite",
config: TextCleanerConfig | str | None = None,
batch_size: int = 64,
num_proc: int | None = None,
score: bool = False,
schema: FieldSchema | None = None,
context: DetectionContext | None = None,
registry_factory: Callable[
[TextCleanerConfig], DetectorRegistry
]
| None = None,
**map_kwargs: Any,
) -> Any
Return ds with columns cleaned (Dataset or IterableDataset).
Run it under if __name__ == "__main__": when num_proc > 1.
Custom registries bypass cache reuse unless new_fingerprint supplies a
caller-owned identity for the complete input, configuration, provider and model behavior.
datatrove ¶
DataTrove pipeline step (pip install squeakycleantext[datatrove]).
SCTCleaner ¶
SCTCleaner(
columns: Sequence[str] = ("text",),
output: str = "overwrite",
config: TextCleanerConfig | str | None = None,
batch_size: int = 64,
*,
schema: FieldSchema | None = None,
context: DetectionContext | None = None,
registry_factory: Callable[
[TextCleanerConfig], DetectorRegistry
]
| None = None,
)
Bases: PipelineStep
Clean doc.text (and listed doc.metadata keys); doc.metadata["sct"] gets the signals.
Place it after language and quality filters. The cleaner is built inside each worker on first use.
langchain ¶
LangChain document transformer (pip install squeakycleantext[langchain]).
SCTDocumentTransformer ¶
SCTDocumentTransformer(
columns: Sequence[str] = ("page_content",),
output: str = "overwrite",
config: TextCleanerConfig | str | None = None,
*,
schema: FieldSchema | None = None,
context: DetectionContext | None = None,
registry_factory: Callable[
[TextCleanerConfig], DetectorRegistry
]
| None = None,
)
Bases: BaseDocumentTransformer
Clean page_content (and listed metadata keys); metadata["sct"] gets the signals.
Returns new documents; the inputs are not modified.
transform_documents ¶
haystack ¶
Haystack component (pip install squeakycleantext[haystack]).
SCTDocumentCleaner ¶
SCTDocumentCleaner(
columns: Sequence[str] = ("content",),
output: str = "overwrite",
config: TextCleanerConfig | str | None = None,
*,
schema: FieldSchema | None = None,
context: DetectionContext | None = None,
registry_factory: Callable[
[TextCleanerConfig], DetectorRegistry
]
| None = None,
)
Clean content (and listed meta keys); meta["sct"] gets the signals.
Returns new documents with ids recomputed from the cleaned content.
to_dict ¶
Preset names stay names; a config keeps only its non-default fields.
Haystack raises SerializationError for values it cannot store (custom steps).