suggest_terms#
- scikitplot.cleanprompt.suggest_terms(text, result=None, min_tokens=1, max_suggestions=40)[source]#
Offer candidate terms the active detectors did not claim.
- Parameters:
- textstr
The original text.
- resultRedactionResult, optional
A completed redaction. Anything already redacted is excluded, so the list only ever contains things still in the clear.
- min_tokensint, default=1
Least number of capitalised words a candidate must have.
2narrows to multi-word names such as"Mustafa Kemal";1also offers single words such as"Turkey".- max_suggestionsint, default=40
Most candidates returned, ordered by frequency then first appearance.
- Returns:
- tuple of Suggestion
Candidates for a human to accept or ignore. Nothing here is redacted.
- Raises:
- TypeError
If
textis not a string.
- Parameters:
- Return type:
tuple[Suggestion, …]
Notes
User notes. Accepting a suggestion adds it as an exact term, so the redaction stays precise. This is how to handle names when the
nertier is not installed: look at the list, tick what matters, and those terms are then matched literally.Developer notes. Deliberately high-recall and deliberately advisory. Recall matters because a missed candidate is never shown to the user at all; precision matters less because every candidate is reviewed by a person before anything happens to it. Sentence-opening function words are dropped because offering “The” and “This” trains people to stop reading the list.
Examples
>>> [s.text for s in suggest_terms("Ada Lovelace met Charles Babbage.")] ['Ada Lovelace', 'Charles Babbage']
Gallery examples#
Cleanprompt from Python: Single Calls and Edge Cases