Skip to content

elmiko/social-moments-service

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

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 pip command available.
  • access to the curl command available.
  • (optional) a Python Virtual Environment available.

Procedure

  1. clone this repository and change directory into the cloned location.

  2. install the dependencies.

    pip install -r requirements.txt
    
  3. start the server.

    FLASK_APP=app.py flask run
    
  4. 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 oc command available.

Procedure

  1. login to your OpenShift account and select, or create, a project.

  2. build and deploy the service.

    oc new-app centos/python-36-centos7~https://github.com/elmiko/social-moments-service
    
  3. expose a route to your service.

    oc expose service/social-moments-service
    
  4. 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.

About

an example of a social media sentiment analyzer service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages