Skip to main content

A Bottle API for performing nlp actions on provided text.

Project description

https://img.shields.io/pypi/v/nlp_api.svg https://img.shields.io/travis/William-Lake/nlp_api.svg Documentation Status

A Bottle API for processing text via NLP. Intended for personal use, but built so others can use it as well.

Quickstart

Setup

Installing from pypi

$ pip install nlp-api

Installing from github source

$ git clone https://github.com/William-Lake/NLP-API
$ cd NLP-API
$ python setup.py install

Startup

Help

$ python nlp_api -h

usage: nlp_api [-h] [-v] [host] [port]

A Bottle api for processing text with nlp.

positional arguments:
host           The host NLP-API should run on. Defaults to localhost.
port           The port NLP-API should be available on. Defaults to 8888.

optional arguments:
-h, --help     show this help message and exit
-v, --verbose  Whether or not to provide verbose logging output when running NLP-API.

After pypi installation

$ python -m nlp_api hostname port

After github source installation, executed from the root NLP-API directory

$ python nlp_api hostname port

Endpoints

Note

Requests need to have a json body with the following format:

{
    "text": "Some text to process."
}

Multiple texts can also be accepted by providing a list:

{
    "text": [
        "The first text to process.",
        "The second text to process."
    ]
}

Help

  • /help : Provides help, I.e. a listing of available endpoints and links to useful documentation.

Extraction

  • /snt : Extracts Sentences.
  • /word : Extracts Words.
  • /phrs : Extracts Phrases.
  • /ne : Extracts Named Entities.

Processing

  • /pos : Pos Tags words.
  • /unq : Filters out duplicate items.
  • /rev : Reverses a dictionary of content.
  • /cnsl : Consolidates content to a dictionary.

Calculation

  • /freq : Calculates a Frequency Analysis.
  • /sntmnt : Performs a sentiment analysis.

Mix and match endpoints for different results, E.g.

/word

{
    "action": "WordExtraction",
    "result": [
        "Check",
        "back",
        "tomorrow",
        "...",
        "after",
        "all",
        "."
    ],
    "history": [
        [
            "word",
            "success"
        ]
    ],
    "original": "Check back tomorrow ... after all."
}

/word/freq

{
    "action": "FrequencyCalculation",
    "result": {
        ".": 9,
        "I": 6,
        "the": 6,
        "and": 6,
        "...",
        "bad": 1,
        "after": 1
},
    "history": [
        [
            "word",
            "success"
        ],
        [
            "freq",
            "success"
        ]
    ],
    "original": "Check back tomorrow ... after all."
}
}

If the results you get back aren’t what you expected you likely used a combination that didn’t work out.

You can find more in depth info/examples in the Usage section.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2019-1-7)

  • First release on PyPI.

0.1.1 (2019-1-8)

  • Bug fix re: ImportError post-pypi install.

0.1.2 (2019-1-8)

  • Bug fix re: tox flake8 failing.

0.2.0 (2019-1-9)

  • Changed minimum python version to 3.6.
  • Updated documentation re: pypi installation.
  • Removed the nltk.download command from tox.ini.
  • Added unittests re: /word and /snt.
  • Added travis deployment functionality.
  • Updated dependencies via pyup.
  • Added /help endpoint .

0.2.1 (2019-1-9)

  • Bugfix re: case-insensitive endpoints.

0.3.0 (2019-1-10)

  • Added history to returned content.

0.4.0 (2019-1-11)

  • Added verbose (-v, –verbose) command line option for logging.
  • Output of Consolidation and Content Reversal actions is now sorted by how long the value lists are.
  • Altered test_nlp_api so it determines when the endpoints are ready for testing rather than sleeping.
  • Now accepts multiple texts.

0.4.1 (2019-1-11)

  • Removing some testing code which accidentally made it into 0.4.0.

0.4.2 (2019-1-11)

  • Bugfix re: argparse.
  • Added help/descriptions, available via -h option.

0.4.3 (2019-1-13)

  • Bugfix re: ImportError.

0.5.0 (2019-1-14)

  • Replaced unittest with pytest.
  • Put the /help endpoint in its own method.
  • Added the original text to the returned json.
  • Implemented constants in nlp_api and abstract_action.
  • Added docstrings where needed, updated documentation examples.

Project details


Download files

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

Files for nlp-api, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size nlp_api-0.5.0-py3-none-any.whl (32.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size nlp_api-0.5.0.tar.gz (25.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page