Skip to content

Family Context

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

nlp = edsnlp.blank("eds")
nlp.add_pipe("eds.sentences")
# Dummy matcher
nlp.add_pipe(
    "eds.matcher",
    config=dict(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 :

  1. The family attribute is a boolean, set to True if the component predicts that the span/token relates to a family member.
  2. The family_ property is a human-readable string, computed from the family attribute. It implements a simple getter function that outputs PATIENT or FAMILY, depending on the value of family.

Parameters

PARAMETER DESCRIPTION
nlp

The pipeline object.

TYPE: PipelineProtocol

name

The component name.

TYPE: Optional[str]

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: str DEFAULT: NORM

family

List of terms indicating family reference.

TYPE: Optional[List[str]] DEFAULT: None

termination

List of syntagms termination terms.

TYPE: Optional[List[str]] DEFAULT: None

span_getter

Which entities should be classified. By default, doc.ents

TYPE: SpanGetterArg DEFAULT: None

on_ents_only

Deprecated, use span_getter instead.

Whether to look for matches around detected entities only. Useful for faster inference in downstream tasks.

  • If True, will look in all ents located in doc.ents only
  • If an iterable of string is passed, will additionally look in doc.spans[key] for each key in the iterable

TYPE: Union[bool, str, List[str], Set[str]] DEFAULT: None

explain

Whether to keep track of cues for each entity.

TYPE: bool DEFAULT: False

use_sections

Whether to use annotated sections (namely antécédents familiaux).

TYPE: bool, by default `False` DEFAULT: True

Authors and citation

The eds.family component was developed by AP-HP's Data Science team.