NormalizationPipeline#

class scikitplot.corpus.NormalizationPipeline(steps)[source]#

Apply a sequence of normalisers in order.

Each normaliser in the pipeline receives the output of the previous one. Consecutive built-in steps that only map the text (Unicode, whitespace, HTML, lowercase, duplicate lines) pass the text along and build one document for the run; every other step, a custom one included, receives and returns a document as before. The result is the same document either way.

Parameters:
stepssequence of NormalizerBase

Ordered list of normalisers to apply.

Raises:
ValueError

If steps is empty.

Parameters:

steps (Sequence[NormalizerBase])

Examples

>>> pipeline = NormalizationPipeline(
...     [
...         UnicodeNormalizer(form="NFKC"),
...         HTMLStripNormalizer(),
...         WhitespaceNormalizer(),
...     ]
... )
>>> result = pipeline.normalize_doc(doc)
normalize_batch(docs)[source]#

Apply the pipeline to a list of documents.

Parameters:
docslist[CorpusDocument]
Returns:
list[CorpusDocument]
Parameters:

docs (list[CorpusDocument])

Return type:

list[CorpusDocument]

normalize_doc(doc)[source]#

Apply all normalisers in order.

Parameters:
docCorpusDocument
Returns:
CorpusDocument

Document after all normalisation stages.

Parameters:

doc (CorpusDocument)

Return type:

CorpusDocument