engine_readiness#
- scikitplot.cleanprompt.engine_readiness(name, language='en', model=None, size='sm', check_assets=False)[source]#
Decide whether one engine can run for a language, and how to fix it if not.
- Parameters:
- namestr
"spacy"or"nltk".- languagestr, default=’en’
Language code.
- modelstr, optional
Explicit spaCy model, overriding
languageandsize.- sizestr, default=’sm’
Preferred spaCy model size.
- check_assetsbool, default=False
Also check NLTK’s data packages, which imports NLTK. spaCy’s model is always checked, because that check imports nothing.
- Returns:
- EngineReadiness
The decision, its reason and its remedy.
- Raises:
- PolicyError
If
nameis not a known engine, orsizeis not a known size.
- Parameters:
- Return type:
Notes
Developer notes — the order of the checks is the order of the remedies. Language first, because no installation fixes an engine that cannot read the language. Then the package, because a model cannot be downloaded into a library that is not there. Then the data. The first failure decides the status and the remedy, so a user is told the next step rather than all of them at once.
This is
CP-093.doctor --nerreported entity detection as active on a machine with spaCy installed and no model, and the nextinspect --nerfailed on the missing model; the same for NLTK without its data. Both decisions read the package and never the data. A diagnosis that disagrees with the run it describes is worse than none, because the run is where the user finds out — after deciding the text was safe to send.Examples
>>> engine_readiness("nltk", "de").reason "nltk does not support language 'de'; it handles en"