Skip to content

Linker

The linker will link the detected entities to a existing set of labels. Some of the linkers, however, are end-to-end, i.e. they don't need the mentions extractor, as they detect and link the entities at the same time.

There are 4 linkers available currently, 2 of them are end-to-end and 2 are not. Let's start with those thar are not end-to-end.

Bases: ABC

Linker define a standard interface for entity linking. A Linker may relay on existing extracted mentions or perform end-2-end extraction

entities: List[Entity] property

Entities to link to

Perform the entity linking. Call the predict function and add entities to the Spacy Docs

Parameters:

Name Type Description Default
docs Iterator[Doc]

A list of spacy Document

required
batch_size Optional[Union[int, None]]

The batch size

None

Returns:

Type Description

load_models()

Load the model

Returns:

Type Description

predict(docs, batch_size=None) abstractmethod

Perform the entity prediction

Parameters:

Name Type Description Default
docs Iterator[Doc]

A list of spacy Document

required
batch_size Optional[Union[int, None]]

The batch size

None

Returns:

Type Description
List[List[Span]]

List Spans for each Document in docs

set_device(device)

Set the device to use

Parameters:

Name Type Description Default
device Union[str, device]
required

Returns:

Type Description

set_kg(entities)

Set entities that linker can use

Parameters:

Name Type Description Default
entities Iterator[Entity]

The list of entities

required