Skip to main content

spaCy to JSON-NLP

(C) 2019 by Damir Cavar, Oren Baldinger, Maanvitha Gongalla, Anurag Kumar, Murali Kammili

Brought to you by the NLP-Lab.org!

This only works with spaCy 2.1.0!

I had the same issue. I downgraded Spacy from 2.1.4 to 2.1.0 and numpy to 1.14.5 to resolve.

Introduction

Currently this module requires Python 3.6+.

This module provides a spaCy v2.1 wrapper for JSON-NLP. It takes the spaCy output and generates a JSON-NLP output. It also provides a Microservice wrapper that allows you to launch the spaCy module as a persistent RESTful service using Flask or other WSGI-based server.

Since this microservice is built on spaCy, you will need to have its models download, for example:

python -m spacy download en
python -m spacy download en_core_web_md

Additional Pipeline Modules

spaCy allows for the addition of additional models as pipeline modules. We provide such integrations for coreference and phrase structure trees.

Anaphora and Coreference Resolution

We provide HuggingFace coreference resolution, a fast system tightly integrated into spaCy. Note that the first time the parser is run, it will download the coreference models if they are not already present. These models only work for English.

Phrase Structure Trees (Constituency Parse)

We provide the CPU version of the benepar parser, a highly accurate phrase structure parser. Bear in mind it is a Tensorflow module, as such it has a notable start-up time, and relatively high memory requirements (4GB+).

If you have a GPU available, you can install the GPU version of the module with:

pip install --upgrade benepar[gpu] 

Microservice

The JSON-NLP repository provides a Microservice class, with a pre-built implementation of Flask. To run it, execute:

python spacyjsonnlp/server.py

Since server.py extends the Flask app, a WSGI file would contain:

from spacyjsonnlp.server import app as application

To disable a pipeline component (such as phrase structure parsing), add

application.constituents = False

The full list of properties that can be disabled or enabled are

  • constituents
  • dependencies
  • coreference
  • expressions

The microservice exposes the following URIs:

  • /constituents
  • /dependencies
  • /coreference
  • /expressions
  • /token_list

These URIs are shortcuts to disable the other components of the parse. In all cases, tokenList will be included in the JSON-NLP output. An example url is:

http://localhost:5000/dependencies?text=I am a sentence

Text is provided to the microservice with the text parameter, via either GET or POST. If you pass url as a parameter, the microservice will scrape that url and process the text of the website.

The spaCy language model to use for parsing can be selected with the spacy_model parameter.

Here is an example GET call:

http://localhost:5000?spacy_model=en&constituents=0&text=I am a sentence.

Metadata

Release files for spacyjsonnlp 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spacyjsonnlp 0.1.3
File Size Uploaded
spacyjsonnlp-0.1.3.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spacyjsonnlp 0.1.3
File Interpreter ABI Platform
spacyjsonnlp-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 42.9 kB

Release files / spacyjsonnlp-0.1.3.tar.gz

Download URL spacyjsonnlp-0.1.3.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
77e14d0bb8a407c0d28df8d97aa2e36e8db3e0b5e4fa27cd694a5b9b8750312b
BLAKE2b-256 checksum
How to use checksums
350a0fb2c97b5c2a881ecc3ba2504961a9ebe5667256ff08b921250e4df945ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release files / spacyjsonnlp-0.1.3-py3-none-any.whl

Download URL spacyjsonnlp-0.1.3-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55cca4a3b2d607c29b49fb3ed1a00184a22d6e289dfb156fc7596ff9fdefaff5
BLAKE2b-256 checksum
How to use checksums
3de449e88e9d37dad8e4635ec3f0495d99e75741250ab15090ed8cfc5154584a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page