edsnlp.core.registries
DraftPipe [source]
Bases: Draft[T]
maybe_nlp [source]
If the factory requires an nlp argument and the user has explicitly provided it (this is unusual, we usually expect the factory to be instantiated via add_pipe, or a config), then we should instantiate it.
| RETURNS | DESCRIPTION |
|---|---|
Union[PartialFactory, Any] | |
instantiate [source]
To ensure compatibility with spaCy's API, we need to support passing in the nlp object and name to factories. Since they can be nested, we need to add them to every factory in the config.
FactoryRegistry [source]
Bases: Registry
A registry that validates the input arguments of the registered functions.
get [source]
Get the registered function for a given name. Since we want to be able to get functions registered under spacy namespace, and functions defined in memory but not accessible via entry points (spacy internal namespace), we need to check multiple registries.
The strategy is the following:
- If the function exists in the edsnlp_factories namespace, return it as a curried function.
- Otherwise, check spacy namespaces and re-register it under edsnlp_factories namespace, then return it as a curried function.
- Otherwise, search in edsnlp's entry points and redo steps 1 & 2
- Otherwise, search in spacy's points and redo steps 1 & 2
- Fail
name (str): The name. RETURNS (Any): The registered function.
register [source]
This is a convenience wrapper around confit.Registry.register, that curries the function to be registered, allowing to instantiate the class later once nlp and name are known.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
name | TYPE: |
func | TYPE: |
default_config | TYPE: |
assigns | TYPE: |
requires | TYPE: |
retokenizes | TYPE: |
default_score_weights | TYPE: |
invoker | TYPE: |
deprecated | TYPE: |
spacy_compatible | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Callable[[InFunc], InFunc] | |
accepted_arguments [source]
Checks that a function accepts a list of keyword arguments
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
func | Function to check TYPE: |
args | Argument or list of arguments to check TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
List[str] | |