Code Monkey home page Code Monkey logo

nlp_api's Introduction

NLP API

This project provides an API to a variety of NLP libraries, in a standard format. Returns document sentiment, keywords, and entities. Can return sentiment per keyword and per entity.

Also can be used to set up your own text analysis API server.

Usage

Some input:

text = """
Edmonton is the capital city of the Canadian province of Alberta. Edmonton is on the North Saskatchewan River and
is the centre of the Edmonton Metropolitan Region, which is surrounded by Alberta's central region. The city anchors
the north end of what Statistics Canada defines as the "Calgary–Edmonton Corridor".

The city had a population of 932,546 in 2016, making it Alberta's second-largest city and Canada's fifth-largest
municipality. Also in 2016, Edmonton had a metropolitan population of 1,321,426, making it the sixth-largest census
metropolitan area (CMA) in Canada. Edmonton is North America's northernmost city with a metropolitan population over
one million. A resident of Edmonton is known as an Edmontonian.

Edmonton's historic growth has been facilitated through the absorption of five adjacent urban municipalities
(Strathcona, North Edmonton, West Edmonton, Beverly and Jasper Place) and a series of annexations ending in 1982.
Known as the "Gateway to the North", the city is a staging point for large-scale oil sands projects occurring in
northern Alberta and large-scale diamond mining operations in the Northwest Territories.

Edmonton is a cultural, governmental and educational centre. It hosts a year-round slate of festivals, reflected in
the nickname "Canada's Festival City". It is home to North America's largest mall, West Edmonton Mall (the world's
largest mall from 1981 until 2004), and Fort Edmonton Park, Canada's largest living history museum
"""

Using the code:

import analyze_text as at
result = at.analyze_text_block(text)
import pprint
pprint.pprint(result)

You can also specify which libraries to use:

result = at.analyze_text_block(text, sentiment_library = "vader", entity_library = "textblob")

Flask REST Server

Run the flask server:

nohup python rest_server.py >/dev/null 2>&1 &

Query the server (from python):

from requests import put
host_url = 'host.url.com/analyze_text'
put(host_url, data={'text': text}).json()

Query the server (from the command line):

curl -X PUT -d text="hello there i am some text to analyze in Canada. Boy oh boy am I angry." host.url.com/analyze_text

nlp_api's People

Contributors

reisner avatar

Stargazers

 avatar  avatar Jared Rewerts avatar Ben Gready avatar

Watchers

 avatar James Cloos avatar Ben Gready avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.