FluentCleanPrompt#

class scikitplot.cleanprompt.FluentCleanPrompt(plan=None)[source]#

Build a CleanPlan one decision at a time.

Parameters:
planCleanPlan, optional

Start from an existing plan. Defaults to packs('auto') over every format, placeholders, core patterns on, no entity engine.

Parameters:

plan (CleanPlan | None)

Notes

User notes. Every method returns a new builder. Each domain may be set once; set it again with conflict='replace' to overwrite or conflict='extend' to add to it.

Examples

>>> plan = FluentCleanPrompt().packs("patient").formats("csv").plan()
>>> plan.packs, plan.formats
(('patient',), ('csv',))
>>> FluentCleanPrompt().packs("patient").packs("finance")
Traceback (most recent call last):
...
scikitplot.cleanprompt._exceptions.CleanPromptError: packs is already set to ('patient',); pass conflict='replace' or conflict='extend'
>>> sorted(
...     FluentCleanPrompt()
...     .packs("patient")
...     .packs("finance", conflict="extend")
...     .plan()
...     .packs
... )
['finance', 'patient']
allow(*terms, conflict='error')[source]#

Never hide these exact strings.

Parameters:
Return type:

FluentCleanPrompt

build()[source]#

Return the plan, or raise listing every problem with it.

Returns:
CleanPlan

Validated.

Raises:
CleanPromptError

With one line per problem.

Return type:

CleanPlan

core(enabled=True, conflict='error')[source]#

Turn the built-in structural patterns on or off.

Parameters:
Return type:

FluentCleanPrompt

custom(*paths, conflict='error', replace_builtins=False)[source]#

Add custom pack or format definitions from YAML or JSON files.

Parameters:
*pathsstr

Definition files.

conflict{‘error’, ‘replace’, ‘extend’}, default=’error’

What to do if custom files were already given.

replace_builtinsbool, default=False

Let a custom definition replace a built-in of the same name.

Returns:
FluentCleanPrompt

A new builder.

Parameters:
  • paths (str)

  • conflict (str)

  • replace_builtins (bool)

Return type:

FluentCleanPrompt

formats(*names, conflict='error')[source]#

Choose which formats are read: names, extensions, or 'all'.

Parameters:
*namesstr

Format names ('csv'), extensions ('.env') or 'all'.

conflict{‘error’, ‘replace’, ‘extend’}, default=’error’

What to do if formats were already chosen.

Returns:
FluentCleanPrompt

A new builder.

Parameters:
Return type:

FluentCleanPrompt

guard(format='text', verify=True)[source]#

Return a Guard for this plan.

Parameters:
formatstr, default=’text’

How prompts are read.

verifybool, default=True

Refuse to send when the independent leak check finds a value.

Returns:
Guard

Ready to put in front of any model client.

Parameters:
hide(*terms, conflict='error')[source]#

Hide these exact strings wherever they appear.

Parameters:
Return type:

FluentCleanPrompt

infer_roles(enabled=True, conflict='error')[source]#

Guess column roles from their names; reported as inferred.

Parameters:
Return type:

FluentCleanPrompt

keep(*parts, conflict='error')[source]#

Send artefact parts removed by default: outputs, figures, paths.

Parameters:
Return type:

FluentCleanPrompt

materialize()[source]#

Return a Cleaner for this plan.

Returns:
Cleaner

Ready to encode text, files, directories and archives.

Raises:
CleanPromptError

If the plan does not validate, or an entity engine it asks for is not usable.

ner(engine='auto', language='en', conflict='error')[source]#

Turn on entity detection with auto, spacy, nltk or both.

Parameters:
Return type:

FluentCleanPrompt

packs(*names, conflict='error')[source]#

Choose packs: names, or 'all', 'auto' or 'none'.

Parameters:
*namesstr

One or more pack names, or a single mode keyword.

conflict{‘error’, ‘replace’, ‘extend’}, default=’error’

What to do if packs were already chosen.

Returns:
FluentCleanPrompt

A new builder.

Parameters:
Return type:

FluentCleanPrompt

pattern_risk(mode, conflict='error')[source]#

Choose what a risky custom pattern does: warn, ignore or refuse.

Parameters:
mode{‘warn’, ‘ignore’, ‘refuse’}

warn loads the pattern and says what was found and how to fix or accept it; ignore loads it silently; refuse makes the plan invalid until the pattern is rewritten or accepted in its pack (risk: accepted with a risk_reason).

conflict{‘error’, ‘replace’}, default=’error’

What to do if a mode was already chosen.

Returns:
FluentCleanPrompt

A new builder.

Raises:
CleanPromptError

If mode is not one of the three.

Parameters:
Return type:

FluentCleanPrompt

plan()[source]#

Return the plan as it stands, without validating it.

Return type:

CleanPlan

profile(name, conflict='error')[source]#

Choose the core-pattern profile: minimal, balanced or strict.

Parameters:
Return type:

FluentCleanPrompt

remember(enabled=True, conflict='error')[source]#

Hide a value everywhere once it has been hidden anywhere (default on).

Notes

User notes. A patient’s name found in the name column of a CSV is then also hidden in the free-text note encoded after it, where no field rule could see it. Turn it off only when you need each file’s output to be independent of what was encoded before.

Parameters:
Return type:

FluentCleanPrompt

roles(mapping=None, conflict='error', **named)[source]#

Declare column roles, e.g. roles(churned="target").

Parameters:
Return type:

FluentCleanPrompt

style(name, conflict='error')[source]#

Choose placeholder ([EMAIL-1]) or surrogate stand-ins.

Parameters:
Return type:

FluentCleanPrompt

surrogates(path, conflict='error')[source]#

Use a custom surrogate set’s names (needs style('surrogate')).

Parameters:
pathstr

A .yaml, .yml or .json surrogate set.

conflict{‘error’, ‘replace’}, default=’error’

What to do if a set was already chosen.

Returns:
FluentCleanPrompt

A new builder. The set is loaded and checked by validate.

Parameters:
Return type:

FluentCleanPrompt

validate()[source]#

Return every problem with the plan; empty when it can run.

Return type:

list[str]