Social Moments Service
This service deploys an HTTP server that will generate sentiment analysis
on all text that is sent. When deployed, sending a POST request to / with
the body containing sentences in English will cause the service to return an
array of sentiment scores corresponding to the sentences.
Quickstart
Prerequisites
- a shell with Python 3.4+ available.
- access to the
pipcommand available. - access to the
curlcommand available. - (optional) a Python Virtual Environment available.
Procedure
-
clone this repository and change directory into the cloned location.
-
install the dependencies.
pip install -r requirements.txt -
start the server.
FLASK_APP=app.py flask run -
access the service with curl
curl http://localhost:5000 \ -H "Content-Type: application/json" \ -d "I love applesauce!"
If everything has worked you will see a result from the service that looks similar to this:
[{"compound": 0.6696, "neg": 0.0, "neu": 0.182, "pos": 0.818}]
Launch on OpenShift
This repository has been designed to be deployable on OpenShift using the source-to-image workflow. As such, you can directly deploy this code into a container on OpenShift.
Prerequisites
- access to an OpenShift cluster available.
- a shell with access to the
occommand available.
Procedure
-
login to your OpenShift account and select, or create, a project.
-
build and deploy the service.
oc new-app centos/python-36-centos7~https://github.com/elmiko/social-moments-service -
expose a route to your service.
oc expose service/social-moments-service -
access the service with curl.
curl http://`oc get routes/social-moments-service --template='{{.spec.host}}'` \ -H "Content-Type: application/json" \ -d "I love applesauce!"
If everything has worked you will see a result similar to one in the previous example.