Sentences
The eds.sentences matcher provides an alternative to spaCy's default sentencizer, aiming to overcome some of its limitations.
Indeed, the sentencizer merely looks at period characters to detect the end of a sentence, a strategy that often fails in a clinical note settings. Our eds.sentences component also classifies end-of-lines as sentence boundaries if the subsequent token begins with an uppercase character, leading to slightly better performances.
Moreover, the eds.sentences component use the output of the eds.normalizer and eds.endlines output by default when these components are added to the pipeline.
Examples
import edsnlp
nlp = edsnlp.blank("eds")
nlp.add_pipe("eds.sentences")
text = """Le patient est admis le 23 août 2021 pour une douleur à l'estomac
Il lui était arrivé la même chose il y a deux ans."
"""
doc = nlp(text)
for sentence in doc.sents:
print("<s>", sentence, "</s>")
# Out: <s> Le patient est admis le 23 août 2021 pour une douleur à l'estomac
# Out: <\s>
# Out: <s> Il lui était arrivé la même chose il y a deux ans. <\s>
import edsnlp
nlp = edsnlp.blank("eds")
nlp.add_pipe("sentencizer")
text = """Le patient est admis le 23 août 2021 pour une douleur à l'estomac"
Il lui était arrivé la même chose il y a deux ans.
"""
doc = nlp(text)
for sentence in doc.sents:
print("<s>", sentence, "</s>")
# Out: <s> Le patient est admis le 23 août 2021 pour une douleur à l'estomac
# Out: Il lui était arrivé la même chose il y a deux ans. <\s>
Notice how EDS-NLP's implementation is more robust to ill-defined sentence endings.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
nlp | The pipeline object. TYPE: |
name | The name of the component. TYPE: |
punct_chars | Punctuation characters. TYPE: |
use_endlines | Whether to use endlines prediction. TYPE: |
ignore_excluded | Whether to skip excluded tokens (requires the upstream TYPE: |
Authors and citation
The eds.sentences component was developed by AP-HP's Data Science team.