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. 2 narrows to multi-word names such as "Mustafa Kemal"; 1 also 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 text is not a string.

Parameters:
  • text (str)

  • result (RedactionResult | None)

  • min_tokens (int)

  • max_suggestions (int)

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 ner tier 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']