edsnlp.pipes.core.contextual_matcher.contextual_matcher
ContextualMatcher
Bases: BaseNERComponent
Allows additional matching in the surrounding context of the main match group, for qualification/filtering.
Parameters
| PARAMETER | DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
nlp | spaCy TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name | The name of the pipe TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
patterns | The patterns to match
TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
assign_as_span | Whether to store eventual extractions defined via the TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
attr | Attribute to match on, eg TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ignore_excluded | Whether to skip excluded tokens during matching. TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ignore_space_tokens | Whether to skip space tokens during matching. TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
alignment_mode | Overwrite alignment mode. TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
regex_flags | RegExp flags to use when matching, filtering and assigning (See here) TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
include_assigned | Whether to include (eventual) assign matches to the final entity TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label_name | Deprecated, use TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label | The label to assign to the matched entities TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
span_setter | How to set matches on the doc TYPE: |
set_extensions
Define the extensions used by the component
filter_one
Filter extracted entity based on the exclusion and inclusion filters of the configuration.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
span | Span to filter TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Optional[Span] | None if the span was filtered, the span else |
assign_one
Get additional information in the context of each entity. This function will populate two custom attributes:
ent._.sourceent._.assigned, a dictionary with all retrieved information
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
span | Span to enrich TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
List[Span] | Spans with additional information |
process_one
Processes one span, applying both the filters and the assignments
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
span | Span object TYPE: |
pattern | TYPE: |
| YIELDS | DESCRIPTION |
|---|---|
span | Filtered spans, with optional assignments |
process
Process the document, looking for named entities.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
doc | spaCy Doc object TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
List[Span] | List of detected spans. |
__call__
Adds spans to document.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
doc | spaCy Doc object TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
doc | spaCy Doc object, annotated for extracted terms. TYPE: |