medkit.text.spacy.pipeline
medkit.text.spacy.pipeline#
Classes:
|
Segment annotator relying on a Spacy pipeline |
- class SpacyPipeline(nlp, spacy_entities=None, spacy_span_groups=None, spacy_attrs=None, medkit_attribute_factories=None, name=None, uid=None)[source]#
Segment annotator relying on a Spacy pipeline
Initialize the segment annotator
- Parameters
nlp (
Language
) – Language object with the loaded pipeline from Spacyspacy_entities (
Optional
[List
[str
]]) – Labels of new spacy entities (doc.ents) to convert into medkit entities. If None (default) all the new spacy entities will be convertedspacy_span_groups (
Optional
[List
[str
]]) – Name of new spacy span groups (doc.spans) to convert into medkit segments. If None (default) new spacy span groups will be convertedspacy_attrs (
Optional
[List
[str
]]) – Name of span extensions to convert into medkit attributes. If None (default) all non-None extensions will be added for each annotation with a medkit ID.medkit_attribute_factories (
Optional
[Dict
[str
,Callable
[[Span
,str
],Attribute
]]]) – Mapping of factories in charge of converting spacy attributes to medkit attributes. Factories will receive a spacy span and an an attribute label when called. The key in the mapping is the attribute label.name (
Optional
[str
]) – Name describing the pipeline (defaults to the class name).uid (str) – Identifier of the pipeline
Methods:
run
(segments)Run a spacy pipeline on a list of segments provided as input and returns a new list of segments.
set_prov_tracer
(prov_tracer)Enable provenance tracing.
Attributes:
Contains all the operation init parameters.
- run(segments)[source]#
Run a spacy pipeline on a list of segments provided as input and returns a new list of segments. Each segment is converted to spacy document (Doc object). Then, the spacy pipeline is executed and finally, the new annotations and attributes are converted into medkit annotations.
- property description: medkit.core.operation_desc.OperationDescription#
Contains all the operation init parameters.
- Return type
- set_prov_tracer(prov_tracer)#
Enable provenance tracing.
- Parameters
prov_tracer (
ProvTracer
) – The provenance tracer used to trace the provenance.