skillfed

negspacy

A spaCy pipeline component for negating concepts in text (NegEx).

negspacy v1.1.0 121.3K downloads/30d#11,987 on PyPI279
Permissive 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) Active released

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 negspacy

uv

uv add negspacy

poetry

poetry add negspacy

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Scientific/EngineeringTyping :: Typed

Tags

negation detection spacynegex algorithm nlpclinical text negationentity negation spacy pipelinenegate concepts nlpnegation in medical textspacy negation component
negation-detectionclinical-nlpspacy-component

More Scientific/Engineering packages