resolve_engine#

scikitplot.cleanprompt.resolve_engine(mode='auto', language='en', model=None, size='sm', check_assets=False)[source]#

Resolve an engine mode into the engines that will actually run.

Parameters:
modestr, default=’auto’

One of ENGINE_MODES.

languagestr, default=’en’

Language code, used to rule out engines that cannot handle it.

modelstr, optional

Explicit spaCy model, used when judging whether spaCy is ready.

sizestr, default=’sm’

Preferred spaCy model size, used the same way.

check_assetsbool, default=False

Also check NLTK’s data packages when auto considers NLTK. See engine_readiness.

Returns:
tuple of str

Engine names to run, possibly empty.

Raises:
PolicyError

If mode is not a known mode.

Parameters:
Return type:

tuple[str, …]

Notes

Developer notes. auto resolves by readiness, not by presence: an engine whose package is absent, broken, unable to read the language or missing its data is skipped, because it would detect nothing either way. Before CP-093 it resolved by package presence alone, so a machine with spaCy installed and no model chose spaCy over a working NLTK and then failed on the first sentence.

An explicitly named engine is not silently dropped when it is not ready — the caller asked for it by name, and quietly running without it would be the silent degradation this submodule exists to prevent. It is returned; build_detectors with required=True refuses it with its own remedy, and without required the detector raises on first use.

Examples

>>> resolve_engine("none")
()
>>> resolve_engine("nltk", "en")
('nltk',)
>>> resolve_engine("nltk", "de")
('nltk',)