negspacy
A spaCy pipeline component for negating concepts in text (NegEx).
What it is and what it does
negspacy is a spaCy pipeline component that detects negation in text using the NegEx algorithm, originally developed for clinical discharge summaries. It adds a negation attribute to entities and spans, marking whether they are negated in context. The package works by matching negation patterns (preceding negations like 'not', following negations like 'declined', pseudo-negations that are false triggers, and termination phrases like 'but' that reset negation scope) against text around recognized entities.
The package provides three built-in termset configurations: general English (en), clinical English (en_clinical, the default), and a more sensitive clinical variant. Users can customize patterns on the fly, apply negation detection to entity spans or noun chunks, and integrate it into any spaCy 3.0+ pipeline. It's designed for information extraction tasks where distinguishing between asserted and negated concepts matters—particularly in clinical NLP but applicable to any domain where negation context affects meaning.
Use it for:
- Extract medical findings from clinical notes while correctly identifying which conditions are negated or ruled out.
- Build clinical decision support systems that distinguish between patient symptoms present versus absent.
- Process scientific literature to identify negated claims or non-findings in research abstracts.
- Improve entity extraction accuracy in domains where negation reverses the semantic meaning of a mention.
- Analyze customer feedback or survey responses to separate complaints from things customers explicitly do not want.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds negation detection to spaCy pipelines using the NegEx algorithm, marking whether named entities or spans in text are negated.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, permissive licensing, and fills a specific need in NLP pipelines where negation context matters. Best suited for clinical or scientific text processing; general-purpose NLP projects may not need it unless negation handling is a core requirement.
Install
negspacy on PyPI
pip
pip install negspacyuv
uv add negspacypoetry
poetry add negspacyInstalling negspacy
Before you install
Low friction install with a single runtime dependency on spacy. Actively maintained as of 2026-04-20 with 279 repository stars and recent activity.
License in practice
MIT License permits unrestricted use, modification, and distribution with no warranty or liability constraints.
Quickstart
pip install negspacy
import spacy
from negspacy.negation import Negex
nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("negex")
doc = nlp("She does not like Steve Jobs.")
for e in doc.ents:
print(e.text, e._.negex)
Requires a spaCy language model to be installed separately (e.g., en_core_web_sm). Requires Python >= 3.10.
Verify before relying
- Whether the NegEx algorithm's accuracy or performance characteristics are documented or tested against standard benchmarks.
- Whether the package works with spaCy models beyond en_core_web_sm or if there are known compatibility limitations.
Package facts
| License | MIT License Copyright (c) 2019 Jeno Pizarro Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — spacy |
| Maintenance | actively maintained — 116 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 121,299/month — #11,987 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: negspacy-1.1.0-py3-none-any.whl
Keywords: clinical, negation, nlp, spacy
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
date-spacyAdds a spaCy pipeline component that identifies…
permissive · top 15,000 on PyPI
spacy-language-detectionAdds language detection to spaCy pipelines at…
copyleft · top 5,000 on PyPI
spacyspaCy is an industrial-strength NLP library…
permissive · top 1,000 on PyPI
pytextrankPyTextRank implements graph-based TextRank and…
permissive · top 15,000 on PyPI
textacytextacy extends spaCy's NLP capabilities with…
permissive · top 15,000 on PyPI
spacy-transformersIntegrates pretrained transformer models (BERT,…
permissive · top 15,000 on PyPI
ja-ginzaA pre-trained Japanese NLP model for spaCy that…
permissive · top 15,000 on PyPI
PyRuSHPyRuSH segments clinical and telegraphic text…
permissive · top 15,000 on PyPI
pysbdDetects sentence boundaries in text using…
permissive · top 5,000 on PyPI
flairFlair is a PyTorch-based NLP framework that…
permissive · top 15,000 on PyPI