Skip to content

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:

  1. If the function exists in the edsnlp_factories namespace, return it as a curried function.
  2. Otherwise, check spacy namespaces and re-register it under edsnlp_factories namespace, then return it as a curried function.
  3. Otherwise, search in edsnlp's entry points and redo steps 1 & 2
  4. Otherwise, search in spacy's points and redo steps 1 & 2
  5. 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: str

func

TYPE: Optional[InFunc] DEFAULT: None

default_config

TYPE: Dict[str, Any] DEFAULT: FrozenDict()

assigns

TYPE: Iterable[str] DEFAULT: FrozenList()

requires

TYPE: Iterable[str] DEFAULT: FrozenList()

retokenizes

TYPE: bool DEFAULT: False

default_score_weights

TYPE: Dict[str, Optional[float]] DEFAULT: FrozenDict()

invoker

TYPE: Callable DEFAULT: None

deprecated

TYPE: Sequence[str] DEFAULT: ()

spacy_compatible

TYPE: bool DEFAULT: True

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: Callable

args

Argument or list of arguments to check

TYPE: Sequence[str]

RETURNS DESCRIPTION
List[str]