SimpleFrequencyEnricher#

class scikitplot.corpus.SimpleFrequencyEnricher(spec=None, *, min_token_length=None, max_keywords=None, lowercase=None, token_pattern=None)[source]#

Populate tokens and deterministic frequency-ranked keywords.

The implementation is intentionally small and dependency-free. It uses normalized_text when available, otherwise text. Existing tokens or keywords are preserved when overwrite=False; if tokens already exist but keywords do not, those tokens are reused to derive keywords.

Parameters:
specSimpleEnricherSpec or None, optional

Declarative configuration. If omitted, keyword overrides can be passed directly for convenience.

min_token_lengthint or None, keyword-only

Convenience override used only when spec is omitted.

max_keywordsint or None, keyword-only

Convenience override used only when spec is omitted.

lowercasebool or None, keyword-only

Convenience override used only when spec is omitted.

token_patternstr or None, keyword-only

Convenience override used only when spec is omitted.

Parameters:

Examples

>>> enricher = SimpleFrequencyEnricher(min_token_length=2, max_keywords=3)
>>> enricher.spec.max_keywords
3
enrich_documents(documents, *, overwrite=False)[source]#

Return copy-on-write documents with tokens and keywords populated.

Parameters:
Return type:

list[CorpusDocument]

property max_keywords: int#

Maximum keyword count from spec.

property min_token_length: int#

Minimum token length from spec.

spec: SimpleEnricherSpec[source]#