Registry¤
The registry
component of Scrubber
maintains
a catalogue of registered functions that can be imported individually as
needed. The registry enables the functions to be referenced by name using
string values. The code registry is created and accessed using the catalogue library by Explosion.
Registered functions can be retrieved individually using lower_case = scrubber_components.get("lower_case")
. Multiple functions can be loaded using the load_components
function:
lexos.scrubber.registry.load_component(s)
¤
Load a single component from a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s |
str
|
The name of the function. |
required |
Source code in lexos\scrubber\registry.py
46 47 48 49 50 51 52 |
|
lexos.scrubber.registry.load_components(t)
¤
Load components from a tuple.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
tuple
|
A tuple containing string names of functions. |
required |
Source code in lexos\scrubber\registry.py
55 56 57 58 59 60 61 62 |
|
Note
Custom functions can be registered by first creating the function and then adding it to the registry. An example is given below:
from lexos.scrubber.registry import scrubber_components
def title_case(text):
"""Convert text to title case using `title()`"""
return text.title()
scrubber_components.register("title_case", func=title_case)