Frailty Mentions[source]
The eds.frailty_mentions pipeline component extracts mentions of frailty. Contrary to most of the other subclasses of FrailtyDomainMatcher, this one does not really match a domain per se, but explicit mentions of frailty itself. The relative rarity of those mentions motivated the development of the matchers for each domain, but it still can be relevant to look for them when trying to categorize a patient's frailty.
Details of the used patterns
# fmt: off
from ..utils import (
ALTERED_STATUS_COMPLEMENTS,
HEALTHY_STATUS_COMPLEMENTS,
make_assign_regex,
normalize_space_characters,
)
# Since the frailty of a function, a tissue or a gene is not the patient frailty, we
# skip it, e.g. `peau fragile`, `fragilite osseuse` or `syndrome de l'X fragile`
non_frailty = [
dict(
regex=make_assign_regex(
[
"thymique",
"cogniti(?:f|ve)",
"nutritionnel(?:le)?",
"osseu",
"cutane",
"peau",
"muqueu",
"mnes",
"memoire",
"executi",
]
)
),
dict(regex=r"\bx\b", window=-2),
]
frail = dict(
source="altered",
regex=[r"\b(?:pre[\s-]?)?fragiles?\b"],
regex_attr="NORM",
exclude=non_frailty,
)
severe = dict(
source="severe",
regex=[
r"(?:extremement|trop) fragiles?\b",
],
regex_attr="NORM",
exclude=non_frailty,
)
frailty = dict(
source="other_frailty",
regex=[r"\bfragilites?\b"],
regex_attr="NORM",
assign=[
dict(
name="healthy_complements",
regex=make_assign_regex(HEALTHY_STATUS_COMPLEMENTS),
window=(-3, 3),
),
dict(
name="altered_complements",
regex=make_assign_regex(ALTERED_STATUS_COMPLEMENTS),
window=(-3, 3),
),
],
exclude=non_frailty,
)
default_patterns = normalize_space_characters([frail, frailty, severe])
# fmt: on
Extensions
On each span span that match, the following attribute is available:
span._.frailty_mentions: set to None.
It will specify the severity of the mention regarding the frailty of the patient.
Possible values are:
healthy: this span suggests the patient is well regarding that domain.altered_nondescript: this span suggests the patient is not well, but it is not yet possible to ascertain the degree of alteration.altered_mild: this span suggests a light alteration regarding this domain.altered_severe: this span suggests a severe alteration regarding this domain.other: this span is not indicative of the level of alteration regarding this domain. Still, it hints that this domain has been evaluated.
Examples
import edsnlp, edsnlp.pipes as eds
nlp = edsnlp.blank("eds")
nlp.add_pipe(eds.sentences())
nlp.add_pipe(eds.normalizer())
nlp.add_pipe(f"eds.frailty_mentions")
Below are a few examples:
text = "Patient trop fragile pour une opération."
doc = nlp(text)
spans = doc.spans["frailty_mentions"]
spans
# Out: [trop fragile]
span = spans[0]
span._.frailty_mentions
# Out: 'altered_severe'
text = "Le patient présente une fragilité thymique."
doc = nlp(text)
spans = doc.spans["frailty_mentions"]
spans
# Out: []
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
nlp | The pipeline TYPE: |
name | The name of the component TYPE: |
patterns | The patterns to use for matching TYPE: |
label | The label to use for the TYPE: |
span_setter | How to set matches on the doc TYPE: |