Family Context[source]
The eds.family
component uses a simple rule-based algorithm to detect spans that describe a family member (or family history) of the patient rather than the patient themself.
Examples
The following snippet matches a simple terminology, and checks the family context of the extracted entities. It is complete, and can be run as is.
import edsnlp, edsnlp.pipes as eds
nlp = edsnlp.blank("eds")
nlp.add_pipe(eds.sentences())
# Dummy matcher
nlp.add_pipe(
eds.matcher(terms=dict(douleur="douleur", osteoporose="ostéoporose")),
)
nlp.add_pipe(eds.family())
text = (
"Le patient est admis le 23 août 2021 pour une douleur au bras. "
"Il a des antécédents familiaux d'ostéoporose"
)
doc = nlp(text)
doc.ents
# Out: (douleur, ostéoporose)
doc.ents[0]._.family
# Out: False
doc.ents[1]._.family
# Out: True
Extensions
The eds.family
component declares two extensions, on both Span
and Token
objects :
- The
family
attribute is a boolean, set toTrue
if the component predicts that the span/token relates to a family member. - The
family_
property is a human-readable string, computed from thefamily
attribute. It implements a simple getter function that outputsPATIENT
orFAMILY
, depending on the value offamily
.
Parameters
PARAMETER | DESCRIPTION |
---|---|
nlp | The pipeline object. TYPE: |
name | The component name. TYPE: |
attr | spaCy's attribute to use: a string with the value "TEXT" or "NORM", or a dict with the key 'term_attr' we can also add a key for each regex. TYPE: |
family | List of terms indicating family reference. TYPE: |
termination | List of syntagms termination terms. TYPE: |
span_getter | Which entities should be classified. By default, TYPE: |
on_ents_only | Deprecated, use Whether to look for matches around detected entities only. Useful for faster inference in downstream tasks.
TYPE: |
explain | Whether to keep track of cues for each entity. TYPE: |
use_sections | Whether to use annotated sections (namely TYPE: |
Authors and citation
The eds.family
component was developed by AP-HP's Data Science team.