jenojp / negspacy

spaCy pipeline object for negating concepts in text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Negation detection for :No terms

deepakm1909 opened this issue · comments

Hi,

For cases like "Blood Transfusion: No" the negation is failing tried adding :No in the termset still no change

nlp = spacy.load("en_core_sci_lg")
ts = termset("en_clinical")
nlp.add_pipe(
"negex",
config={
"chunk_prefix": ["no"]
},
last=True,
)

doc = nlp("Blood Transfusion: No")
for e in doc.ents:
print(e.text, e._.negex)

Output:
Blood Transfusion False

Hey @deepakm1909 - You'll have to add "no" to the "following_negations" list of the termset (see below). You'll just want to make sure this doesn't cause unexpected behavior based on how your documents are set up.

ts = termset("en_clinical")
ts.add_patterns({"following_negations":["no"]})

nlp.add_pipe("negex", config={"chunk_prefix":["no"], "neg_termset":ts.get_patterns()})


# Then doc = nlp("Blood Transfusion: No")

Hi @jenojp Thanks this worked!