Repository: aphp/edsnlp (language: python)

Issue:
eds.negation regex matches on "une" preceding entities which include another negation subtoken
## Description

The negation "preceding_regex" is currently 
```r"ne(?=[ \n]*(?:\w*[ \n]*){3}(?:pas|point|ni|aucun|jamais|rien))"``` 
which matched on patterns such as:
"Situation compliquée d’u**ne** neutropénie fébrile aggravée."
"Le patient est traité d'u**ne** cure d'<ent negated=false>ALECTINIB</ent> depuis le ..."
because of the "ne" and "NI" in entities.

I fixed this thanks to your customizable config but figured i'd give a heads up. 

line 104 in patterns.py
```
preceding_regex = [
    # ne (up to 3 words separated by spaces or newlines) pas/point/...
    r"\bne\b(?=[ \n]*(?:\w*[ \n]*){3}(?:pas|point|ni|aucun|jamais|rien))"
]
```

## How to reproduce the bug
add in test_negation.py line 32: 
```
"Situation aggravée par une <ent negated=false>neutropénie fébrile</ent>."
"Le patient est traité d'une cure d'<ent negated=false>ALECTINIB</ent> depuis le ..."
```

run your pytest



Discussion / hints:

Fix patch:
diff --git a/changelog.md b/changelog.md
index 756260500..273f2a135 100644
--- a/changelog.md
+++ b/changelog.md
@@ -29,6 +29,7 @@
   disabled when windows are used (e.g., neither `window=1` equivalent to softmax and
   `window=0`equivalent to default full sequence Viterbi decoding)
 - `eds` tokenizer nows inherits from `spacy.Tokenizer` to avoid typing errors
+- Only match 'ne' negation pattern when not part of another word to avoid false positives cases like `u[ne] cure de 10 jours`
 
 ## v0.10.5
 
diff --git a/edsnlp/pipes/qualifiers/negation/patterns.py b/edsnlp/pipes/qualifiers/negation/patterns.py
index 35ba440d0..639d34e30 100644
--- a/edsnlp/pipes/qualifiers/negation/patterns.py
+++ b/edsnlp/pipes/qualifiers/negation/patterns.py
@@ -103,7 +103,7 @@
 
 preceding_regex = [
     # ne (up to 3 words separated by spaces or newlines) pas/point/...
-    r"ne(?=[ \n]*(?:\w*[ \n]*){3}(?:pas|point|ni|aucun|jamais|rien))"
+    r"\bne\b(?=[ \n]*(?:\w*[ \n]*){3}(?:pas|point|ni|aucun|jamais|rien))"
 ]
 
 following: List[str] = [


Test patch:
diff --git a/tests/pipelines/qualifiers/test_negation.py b/tests/pipelines/qualifiers/test_negation.py
index dbe13d538..0762eb323 100644
--- a/tests/pipelines/qualifiers/test_negation.py
+++ b/tests/pipelines/qualifiers/test_negation.py
@@ -29,6 +29,8 @@
     "Le patient ne <ent negated=false>fume</ent> que des cigares.",
     "Le résultat exclut un <ent negated=true>SMD</ent>",
     "Le résultat ne permet pas d'exclure un <ent negated=false>SMD</ent>",
+    "Situation aggravée par une <ent negated=false>neutropénie fébrile</ent>."
+    "Patient est traité d'une cure d'<ent negated=false>ALECTINIB</ent> depuis le ...",
 ]