CustomTokenizerRegistry#

class scikitplot.corpus.CustomTokenizerRegistry(kind)[source]#

Thread-safe(ish) module-level registry for named custom components.

Each registry holds a dict[str, Protocol] accessible via module-level helpers (register_tokenizer, get_tokenizer, etc.).

Raises:
KeyError

get raises KeyError when the name is not registered.

Parameters:

kind (str)

Notes

Developer note: The registry is intentionally not thread-locked. Registration happens at import/startup time; concurrent reads during inference are safe because dict lookups in CPython are atomic under the GIL. If you register from a worker thread, synchronize externally.

get(name)[source]#

Retrieve the component registered under name.

Parameters:
namestr

Registry key.

Returns:
object

The registered component.

Raises:
KeyError

If name has not been registered.

Parameters:

name (str)

Return type:

Any

names()[source]#

Return all registered names.

Returns:
list[str]

Sorted list of registered keys.

Return type:

list[str]

register(name, instance)[source]#

Register instance under name.

Parameters:
namestr

Registry key. Must be a non-empty string.

instanceobject

The component instance to register.

Raises:
TypeError

If name is not a str.

ValueError

If name is empty.

Parameters:
Return type:

None