Skip to content

Relations Extractor

The relations extractor will extract relations among different entities previously extracted by a linker..

Currently, the is only one Relation Extractor available: ZS-Bert

Bases: ABC

extract_relations(docs, batch_size=None)

Perform the relations extraction. Call the predict function and add the mentions to the Spacy Doc

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 relations extraction.

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[RelationSpan]]

the predicted relations

set_device(device)

Set the device to use

Parameters:

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

Returns:

Type Description

set_relations(relations)

Set relationships that the relations extractor can use

Parameters:

Name Type Description Default
relations Iterator[Relation]

The list of relationship

required