Registry / ai-ml / negspacy

negspacy

JSON →
library1.1.0pypypiunverified

A spaCy pipeline component implementing the NegEx algorithm for negating concepts in clinical text. Current version: 1.1.0. Release cadence is sporadic.

pip install negspacy
INSTALL
IMPORT
SIG · NEGSPACY
N
negspacy
ai-mlpythonv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Negex
from negspacy import Negex
from negspacy.negation import Negex

Add negspacy NegEx pipe to spaCy pipeline to detect negated entities.

import spacy from negspacy.negation import Negex from negspacy import termsets nlp = spacy.load("en_core_web_sm") nlp.add_pipe("negex", config={"ent_types": ["PERSON", "ORG"]}) # or Negex(nlp, ent_types=["PERSON", "ORG"]) doc = nlp("She does not have breast cancer.") for e in doc.ents: print(e.text, e._.negex)
Debug
Known issues
breakingnegspacy 1.x drops Python 3.6 support and is designed for spaCy 3.x. Ensure spaCy >=3.0 installed.
fix
Upgrade spaCy: pip install spacy>=3.0
affects: >=1.0.0
gotchaThe Negex component must be added after the entity recognizer (ner) in the pipeline; otherwise entities may not be recognized yet.
fix
Add pipe after 'ner': nlp.add_pipe('negex', after='ner')
affects: *
deprecatedUsing Negex(nlp, ...) constructor directly is deprecated; use nlp.add_pipe('negex', config={...}) instead.
fix
Use add_pipe pattern.
affects: >=0.1.0
Upgrade
Version history
1.1.0latest on PyPI · released Apr 20, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Resources
negspacy — pip install negspacy · libregistry