{ "info": { "author": "Jeno Pizarro", "author_email": "jenopizzaro@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Bio-Informatics" ], "description": "

\n\n# negspacy: negation for spaCy\n\n[![Build Status](https://travis-ci.org/jenojp/negspacy.svg?branch=master)](https://travis-ci.org/jenojp/negspacy) [![Built with spaCy](https://img.shields.io/badge/made%20with%20\u2764%20and-spaCy-09a3d5.svg)](https://spacy.io) [![pypi Version](https://img.shields.io/pypi/v/negspacy.svg?style=flat-square)](https://pypi.org/project/negspacy/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/ambv/black)\n\nspaCy pipeline object for negating concepts in text. Based on the NegEx algorithm.\n\n*NegEx - A Simple Algorithm for Identifying Negated Findings and Diseasesin Discharge Summaries\nChapman, Bridewell, Hanbury, Cooper, Buchanan*\n\n## Installation and usage\nInstall the library.\n```bash\npip install negspacy\n```\n\nImport library and spaCy.\n```python\nimport spacy\nfrom negspacy.negation import Negex\n```\n\nLoad spacy language model. Add negspacy pipeline object. Filtering on entity types is optional.\n```python\nnlp = spacy.load(\"en_core_web_sm\")\nnegex = Negex(nlp, ent_types=[\"PERSON\",\"ORG\"])\nnlp.add_pipe(negex, last=True)\n```\n\nView negations.\n```python\ndoc = nlp(\"She does not like Steve Jobs but likes Apple products.\")\n\nfor e in doc.ents:\n\tprint(e.text, e._.negex)\n```\n\n```console\nSteve Jobs True\nApple False\n```\n\nConsider pairing with [scispacy](https://allenai.github.io/scispacy/) to find UMLS concepts in text and process negations.\n\n## NegEx Patterns\n\n* **psuedo_negations** - phrases that are false triggers, ambiguous negations, or double negatives\n* **preceding_negations** - negation phrases that preceed an entity\n* **following_negations** - negation phrases that follow an entity\n* **termination** - phrases that cut a sentence in parts, for purposes of negation detection (.e.g., \"but\")\n\n## Additional Functionality\n\n### Use own patterns or view patterns in use\n\nUse own patterns\n```python\nnlp = spacy.load(\"en_core_web_sm\")\nnegex = Negex(nlp, termination=[\"but\", \"however\", \"nevertheless\", \"except\"])\n```\n\nView patterns in use\n```python\npatterns_dict = negex.get_patterns\n```\n\n### Negations in noun chunks\n\nDepending on the Named Entity Recognition model you are using, you may have negations \"chunked together\" with nouns. For example when using scispacy:\n```python\nnlp = spacy.load(\"en_core_sci_sm\")\ndoc = nlp(\"There is no headache.\")\nfor e in doc.ents:\n print(e.text)\n\n# no headache\n```\nThis would cause the Negex algorithm to miss the preceding negation. To account for this, you can add a ```chunk_prefix```:\n\n```python\nnlp = spacy.load(\"en_core_sci_sm\")\nnegex = Negex(nlp, chunk_prefix = [\"no\"])\nnlp.add_pipe(negex)\ndoc = nlp(\"There is no headache.\")\nfor e in doc.ents:\n print(e.text, e._.negex)\n\n# no headache True\n```\n\n\n## Contributing\n[contributing](https://github.com/jenojp/negspacy/blob/master/CONTRIBUTING.md)\n\n## Authors\n* Jeno Pizarro\n\n## License\n[license](https://github.com/jenojp/negspacy/blob/master/LICENSE)\n\n## API Documentation\n[Docs](https://jenojp.github.io/negspacy/)", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jenojp/negspacy", "keywords": "nlp spacy SpaCy negation", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "negspacy", "package_url": "https://pypi.org/project/negspacy/", "platform": "", "project_url": "https://pypi.org/project/negspacy/", "project_urls": { "Homepage": "https://github.com/jenojp/negspacy" }, "release_url": "https://pypi.org/project/negspacy/0.1.5/", "requires_dist": null, "requires_python": ">=3.6.0", "summary": "A spaCy pipeline object for negation.", "version": "0.1.5" }, "last_serial": 5984240, "releases": { "0.1.0a0": [ { "comment_text": "", "digests": { "md5": "3b7ace79a7645b874f3b002e723cd514", "sha256": "580b658d71378f4847be86ca725138a36627edbddf16a9ffaaf7e657b9c5a2c0" }, "downloads": -1, "filename": "negspacy-0.1.0a0.tar.gz", "has_sig": false, "md5_digest": "3b7ace79a7645b874f3b002e723cd514", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4113, "upload_time": "2019-08-14T23:18:15", "url": "https://files.pythonhosted.org/packages/d8/a4/892af54b4427d79109163a9f63bc7fdcbe500f6fbb5a0931e7a6bdfadaae/negspacy-0.1.0a0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "332b31ba092d4b18b0a63a7d48ea75b6", "sha256": "bc9062e8846e1ef7ae762552725bd04919c259f2a545eadd5bf65454f98a3ddb" }, "downloads": -1, "filename": "negspacy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "332b31ba092d4b18b0a63a7d48ea75b6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4124, "upload_time": "2019-08-16T03:45:27", "url": "https://files.pythonhosted.org/packages/65/c0/ee1aea58099675960c6ce82bcdd88b6b8a6b112f9ee683a7bd800d4178a4/negspacy-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "095ba425b17fc46e86c3da604fcaf316", "sha256": "034b0c9f85b8c6ac003652bee2d3499395d83dc29bb0816ffc863a5aead04151" }, "downloads": -1, "filename": "negspacy-0.1.2.tar.gz", "has_sig": false, "md5_digest": "095ba425b17fc46e86c3da604fcaf316", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 5397, "upload_time": "2019-08-18T18:46:15", "url": "https://files.pythonhosted.org/packages/e4/d2/5cbe8881a54e3cce25d4f2a60968ee03bd3c5b76f3aa367c5ff857df3e98/negspacy-0.1.2.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "88b94e6dda0419457a0b6fc6b13bdd72", "sha256": "9b57d74ad4fa51f87a7fdaba6ce3cdaf42eb8dadc5c1f0460067bab9c0433cba" }, "downloads": -1, "filename": "negspacy-0.1.4.tar.gz", "has_sig": false, "md5_digest": "88b94e6dda0419457a0b6fc6b13bdd72", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 6002, "upload_time": "2019-09-25T14:23:29", "url": "https://files.pythonhosted.org/packages/69/60/166cc1bb19faded5add38ae89a579ba4d7775643a0d1595c1b0b4f82e0be/negspacy-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "808c367908da07fc5b3554ed8482e2f3", "sha256": "92e449be3adb1fb9125b4d6a37881a7770f045985454c9317c08ff61963ad07f" }, "downloads": -1, "filename": "negspacy-0.1.5.tar.gz", "has_sig": false, "md5_digest": "808c367908da07fc5b3554ed8482e2f3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 6387, "upload_time": "2019-10-16T15:31:50", "url": "https://files.pythonhosted.org/packages/76/92/ad9191a7d4819137bc395b47cf321742b800bcd41ab10ac87a61d6da70b1/negspacy-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "808c367908da07fc5b3554ed8482e2f3", "sha256": "92e449be3adb1fb9125b4d6a37881a7770f045985454c9317c08ff61963ad07f" }, "downloads": -1, "filename": "negspacy-0.1.5.tar.gz", "has_sig": false, "md5_digest": "808c367908da07fc5b3554ed8482e2f3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 6387, "upload_time": "2019-10-16T15:31:50", "url": "https://files.pythonhosted.org/packages/76/92/ad9191a7d4819137bc395b47cf321742b800bcd41ab10ac87a61d6da70b1/negspacy-0.1.5.tar.gz" } ] }