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_textwhen available, otherwisetext. Existing tokens or keywords are preserved whenoverwrite=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
specis omitted.- max_keywordsint or None, keyword-only
Convenience override used only when
specis omitted.- lowercasebool or None, keyword-only
Convenience override used only when
specis omitted.- token_patternstr or None, keyword-only
Convenience override used only when
specis omitted.
- Parameters:
spec (SimpleEnricherSpec)
min_token_length (int | None)
max_keywords (int | None)
lowercase (bool | None)
token_pattern (str | None)
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:
documents (Iterable[CorpusDocument])
overwrite (bool)
- Return type:
Gallery examples#
Build and Search a Real Hamlet Corpus with FluentCorpus