Skip to main content

The Python NLTK JSON-NLP package

Project description

NLTK-JSON-NLP

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

Brought to you by the NLP-Lab.org!

Introduction

NLTK wrapper to JSON-NLP. NLTK has a wide variety of capabilities, but for our purposes we are limiting it to WordNet, VerbNet, and FrameNet. Other packages such as spaCy and Flair are more accurately able to annotate things like part of speech tags and dependency parses. See below for instruction on how to unify outputs from multiple packages.

Microservice

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

python nltkjsonnlp/server.py

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

from nltkjsonnlp.server import app as application

Pipeline

JSON-NLP provides a simple Pipeline interface that we implement as NltkPipeline:

pipeline = nltkjsonnlp.NltkPipeline()
print(pipeline.process(text='I am a sentence.'))

Unification

To make the best use of this pipeline, it is best to unify it with a more accurate and complete pipeline such as spaCy-NLP-Json:

class UnifiedPipeline(pyjsonnlp.pipeline.Pipeline):
    def __init__(self):
        super(UnifiedPipeline, self).__init__()
        self.spacy = spacynlpjson.SpacyPipeline()
        self.nltk = nltkjsonnlp.NltkPipeline()

    def process(self, text='', coreferences=True, constituents=False, dependencies=True, expressions=True,
                **kwargs) -> OrderedDict:
        # start with a spacy parse
        spacy_json = self.spacy.process(text, spacy_model='en_core_web_md', constituents=False,
                                        coreferences=coreferences, dependencies=dependencies, expressions=False)
        # the get an nltk parse
        nltk_json = self.nltk.process(text)

        # unify the parses
        return pyjsonnlp.unification.unifier.add_annotation_to_a_from_b(a=spacy_json, 
                                                                        b=nltk_json, annotation='tokens')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nltkjsonnlp-0.0.5.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nltkjsonnlp-0.0.5-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file nltkjsonnlp-0.0.5.tar.gz.

File metadata

  • Download URL: nltkjsonnlp-0.0.5.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for nltkjsonnlp-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a8888bea4ae17184b19ffa76da2ffdc0a4fa813b96cbebba93f8f50bbf71f672
MD5 bf1e7bd566b29a0c82c04ede2079852f
BLAKE2b-256 7a654a17dcba62d2f68d264314f0c85414feab81332f017fc8de5067e7d2131e

See more details on using hashes here.

File details

Details for the file nltkjsonnlp-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: nltkjsonnlp-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for nltkjsonnlp-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0774dae370e7cd8f86721eaa2d62fef50805d48097478ff885c463a8bdc9712d
MD5 dc9f3771116f44d8e8ee62c2dbfe2c6d
BLAKE2b-256 e82b524674f0dd723091d8dac66db1a4e70114ef83b4bad4577a7f535b51abf9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page