Skip to content

edsnlp.pipes.core.contextual_matcher.models

SingleExcludeModel [source]

Bases: BaseModel

A dictionary to define exclusion rules. Exclusion rules are given as Regexes, and if a match is found in the surrounding context of an extraction, the extraction is removed. Note that only take a match into account if it is not inside the anchor span.

Parameters

PARAMETER DESCRIPTION
regex

A single Regex or a list of Regexes

TYPE: ListOrStr

regex_attr

An attributes to overwrite the given attr when matching with Regexes.

TYPE: Optional[str]

regex_flags

Regex flags

TYPE: RegexFlag

span_getter

A span getter to pick the assigned spans from already extracted entities.

TYPE: Optional[SpanGetterArg]

window

Context window to search for patterns around the anchor. Defaults to "sent" ( i.e. the sentence of the anchor span).

TYPE: Optional[ContextWindow]

SingleIncludeModel [source]

Bases: BaseModel

A dictionary to define inclusion rules. Inclusion rules are given as Regexes, and if a match isn't found in the surrounding context of an extraction, the extraction is removed. Note that only take a match into account if it is not inside the anchor span.

Parameters

PARAMETER DESCRIPTION
regex

A single Regex or a list of Regexes

TYPE: ListOrStr

regex_attr

An attributes to overwrite the given attr when matching with Regexes.

TYPE: Optional[str]

regex_flags

Regex flags

TYPE: RegexFlag

span_getter

A span getter to pick the assigned spans from already extracted entities.

TYPE: Optional[SpanGetterArg]

window

Context window to search for patterns around the anchor. Defaults to "sent" ( i.e. the sentence of the anchor span).

TYPE: Optional[ContextWindow]

ExcludeModel

Bases: AsList[SingleExcludeModel]

A list of SingleExcludeModel objects. If a single config is passed, it will be automatically converted to a list of a single element.

IncludeModel

Bases: AsList[SingleIncludeModel]

A list of SingleIncludeModel objects. If a single config is passed, it will be automatically converted to a list of a single element.

SingleAssignModel [source]

Bases: BaseModel

A dictionary to refine the extraction. Similarly to the exclude key, you can provide a dictionary to use on the context before and after the extraction.

Parameters

PARAMETER DESCRIPTION
span_getter

A span getter to pick the assigned spans from already extracted entities in the doc.

TYPE: Optional[SpanGetterArg]

regex

A single Regex or a list of Regexes

TYPE: ListOrStr

regex_attr

An attributes to overwrite the given attr when matching with Regexes.

TYPE: Optional[str]

regex_flags

Regex flags

TYPE: RegexFlag

window

Context window to search for patterns around the anchor. Defaults to "sent" ( i.e. the sentence of the anchor span).

TYPE: Optional[ContextWindow]

replace_entity

If set to True, the match from the corresponding assign key will be used as entity, instead of the main match. See this paragraph

TYPE: Optional[bool]

reduce_mode

Set how multiple assign matches are handled. See the documentation of the reduce_mode parameter

TYPE: Optional[Flags]

required

If set to True, the assign key must match for the extraction to be kept. If it does not match, the extraction is discarded.

TYPE: Optional[str]

name

A name (string)

TYPE: str

AssignModel

Bases: AsList[SingleAssignModel]

A list of SingleAssignModel objects that should have at most one element with replace_entity=True. If a single config is passed, it will be automatically converted to a list of a single element.

SingleConfig [source]

Bases: BaseModel

A single configuration for the contextual matcher.

Parameters

PARAMETER DESCRIPTION
span_getter

A span getter to pick the assigned spans from already extracted entities in the doc.

TYPE: Optional[SpanGetterArg]

regex

A single Regex or a list of Regexes

TYPE: ListOrStr

regex_attr

An attributes to overwrite the given attr when matching with Regexes.

TYPE: Optional[str]

regex_flags

Regex flags

terms

A single term or a list of terms (for exact matches)

TYPE: Union[RegexFlag, int]

exclude
One or more exclusion patterns
PARAMETER DESCRIPTION
regex

A single Regex or a list of Regexes

TYPE: ListOrStr

regex_attr

An attributes to overwrite the given attr when matching with Regexes.

TYPE: Optional[str]

regex_flags

Regex flags

TYPE: RegexFlag

span_getter

A span getter to pick the assigned spans from already extracted entities.

TYPE: Optional[SpanGetterArg]

window

Context window to search for patterns around the anchor. Defaults to "sent" ( i.e. the sentence of the anchor span).

TYPE: Optional[ContextWindow]

TYPE: AsList[SingleExcludeModel]

include
One or more inclusion patterns
PARAMETER DESCRIPTION
regex

A single Regex or a list of Regexes

TYPE: ListOrStr

regex_attr

An attributes to overwrite the given attr when matching with Regexes.

TYPE: Optional[str]

regex_flags

Regex flags

TYPE: RegexFlag

span_getter

A span getter to pick the assigned spans from already extracted entities.

TYPE: Optional[SpanGetterArg]

window

Context window to search for patterns around the anchor. Defaults to "sent" ( i.e. the sentence of the anchor span).

TYPE: Optional[ContextWindow]

TYPE: AsList[SingleIncludeModel]

assign
One or more assignment patterns
PARAMETER DESCRIPTION
span_getter

A span getter to pick the assigned spans from already extracted entities in the doc.

TYPE: Optional[SpanGetterArg]

regex

A single Regex or a list of Regexes

TYPE: ListOrStr

regex_attr

An attributes to overwrite the given attr when matching with Regexes.

TYPE: Optional[str]

regex_flags

Regex flags

TYPE: RegexFlag

window

Context window to search for patterns around the anchor. Defaults to "sent" ( i.e. the sentence of the anchor span).

TYPE: Optional[ContextWindow]

replace_entity

If set to True, the match from the corresponding assign key will be used as entity, instead of the main match. See this paragraph

TYPE: Optional[bool]

reduce_mode

Set how multiple assign matches are handled. See the documentation of the reduce_mode parameter

TYPE: Optional[Flags]

required

If set to True, the assign key must match for the extraction to be kept. If it does not match, the extraction is discarded.

TYPE: Optional[str]

TYPE: AsList[SingleAssignModel]

source

A label describing the pattern

TYPE: str

FullConfig

Bases: AsList[SingleConfig]

A list of SingleConfig objects that should have distinct source fields. If a single config is passed, it will be automatically converted to a list of a single element.