Skip to content

Commit 5d790d2

Browse files
committed
fix: small bug in alcohol and tobacco pipes
1 parent 827f4be commit 5d790d2

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

edsnlp/pipes/ner/behaviors/alcohol/alcohol.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def process(self, doc: Doc) -> List[Span]:
118118
stopped = self.negation.process(span)
119119
if not any(stopped_token.negation for stopped_token in stopped.tokens):
120120
span._.status = 2
121-
122-
if "zero_after" in span._.assigned.keys():
123-
span._.negation = True
121+
else:
122+
if "zero_after" in span._.assigned.keys():
123+
span._.negation = True
124124

125125
yield span

edsnlp/pipes/ner/behaviors/alcohol/patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
regex=[
44
r"\balco[ol]",
55
r"\bethyl",
6-
r"(?<!(25.?)|(sevrage)).?\boh\b",
6+
r"(?<!(25.{0,10}))\boh\b",
77
r"exogenose",
88
r"delirium.tremens",
99
],

tests/pipelines/ner/disorders/alcohol.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
True,
1010
True,
1111
True,
12+
True,
13+
True,
14+
True,
15+
False,
1216
],
1317
detailled_status=[
1418
None,
@@ -20,28 +24,40 @@
2024
None,
2125
"ABSTINENCE",
2226
None,
27+
None,
28+
"ABSTINENCE",
29+
None,
30+
None,
2331
],
2432
negation=[
2533
None,
2634
None,
2735
None,
2836
None,
2937
None,
30-
None,
38+
False,
3139
True,
3240
None,
3341
True,
42+
False,
43+
False,
44+
False,
45+
None,
3446
],
3547
assign=None,
3648
texts=[
3749
"Patient alcoolique.",
3850
"OH chronique.",
3951
"Prise d'alcool occasionnelle",
4052
"Application d'un pansement alcoolisé",
41-
"Alcoolisme sevré",
42-
"Alcoolisme non sevré",
53+
"Présence d'un alcoolisme sevré",
54+
"Présence d'un alcoolisme non sevré",
4355
"Alcool: 0",
4456
"Le patient est en cours de sevrage éthylotabagique",
4557
"Patient alcoolique: non.",
58+
"On a un alcoolique non sevré depuis 10 ans.",
59+
"Alcoolisme sevré",
60+
"Alcoolisme non sevré",
61+
"Dosage vitamines 25-OH",
4662
],
4763
)

tests/pipelines/ner/disorders/test_all.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def check(self):
9999
for ent in ents:
100100
assert ent.label_ == self.disorder
101101
if negation is not None:
102-
assert ent._.negation == negation
102+
if negation:
103+
assert ent._.negation == negation
104+
else:
105+
assert ent._.negation is None
103106

104107
if not ents:
105108
continue

tests/pipelines/ner/disorders/tobacco.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
True,
1010
True,
1111
True,
12+
True,
1213
],
1314
detailled_status=[
1415
None,
@@ -20,6 +21,7 @@
2021
"ABSTINENCE",
2122
None,
2223
None,
24+
None,
2325
],
2426
negation=[
2527
None,
@@ -31,17 +33,19 @@
3133
None,
3234
True,
3335
True,
36+
False,
3437
],
3538
assign=[{"PA": 15}] + 8 * [None],
3639
texts=[
3740
"Tabagisme évalué à 15 PA",
3841
"Patient tabagique",
3942
"Tabagisme festif",
4043
"On a un tabagisme ancien",
41-
"Tabac: 0",
42-
"Tabagisme passif",
43-
"Tabac: sevré depuis 5 ans",
44+
"Pour le tabac: 0",
45+
"Notion de tabagisme passif",
46+
"Concernant le tabac: sevré depuis 5 ans",
4447
"Le patient ne fume aucun truc.",
4548
"Le patient fume 0 PA.",
49+
"On a un tabagique non sevré depuis 10 ans.",
4650
],
4751
)

0 commit comments

Comments
 (0)