Skip to content

Charlson[source]

The eds.charlson component extracts the Charlson Comorbidity Index.

Examples

import edsnlp, edsnlp.pipes as eds

nlp = edsnlp.blank("eds")
nlp.add_pipe(eds.sentences())
nlp.add_pipe(eds.normalizer())
nlp.add_pipe(eds.charlson())

text = """
Charlson à l'admission: 7.
Charlson:
OMS:
"""

doc = nlp(text)
doc.ents
# Out: (Charlson à l'admission: 7,)

We can see that only one occurrence was extracted. The second mention of Charlson in the text doesn't contain any numerical value, so it isn't extracted.

Extensions

Each extraction exposes 2 extensions:

ent = doc.ents[0]

ent._.score_name
# Out: 'charlson'

ent._.score_value
# Out: 7

Parameters

PARAMETER DESCRIPTION
nlp

The pipeline object

TYPE: PipelineProtocol

name

Name of the component

TYPE: Optional[str] DEFAULT: 'charlson'

regex

A list of regexes to identify the score

TYPE: List[str] DEFAULT: regex

attr

Whether to match on the text ('TEXT') or on the normalized text ('NORM')

TYPE: str DEFAULT: 'NORM'

value_extract

Regex with capturing group to get the score value

TYPE: str DEFAULT: value_extract

score_normalization

Function that takes the "raw" value extracted from the value_extract regex and should return:

  • None if no score could be extracted
  • The desired score value else

TYPE: Union[str, Callable[[Union[str, None]], Any]] DEFAULT: score_normalization_str

window

Number of token to include after the score's mention to find the score's value

TYPE: int DEFAULT: 7

ignore_excluded

Whether to ignore excluded spans when matching

TYPE: bool DEFAULT: False

ignore_space_tokens

Whether to ignore space tokens when matching

TYPE: bool DEFAULT: False

flags

Regex flags to use when matching

TYPE: Union[RegexFlag, int] DEFAULT: 0

label

Label name to use for the Span object and the extension

TYPE: str DEFAULT: 'charlson'

span_setter

How to set matches on the doc

TYPE: SpanSetterArg DEFAULT: {'ents': True, 'charlson': True}

RETURNS DESCRIPTION
SimpleScoreMatcher