Vivid-Project / microservice

Micro-service for generating a tone analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tone Analyzer Microservice

View on Heroku!

Contributors Forks Stargazers Issues Build Status

Tone Analyzer Microservice

This is a microservice that was built to provide a tone analysis for a user's dream journal entry.
Explore the docs »

· Report Bug · Request Feature


Table of Contents



About The Project

Please visit the frontend repository of this project and check out the readme there for a more in depth look at this project!

This microservice was built to provide tone analysis data for a user's dream journal entry. This microservice works in tandem with the Vivid-Project backend. When a user saves a dream journal entry it is sent to the Vivid-Project backend where that entry is stored in the database. From there, a request will be issued to this microservice containing a raw text body holding that journal entry. This microservice will analyze this text, sentence by sentence, and will return a "tone strength"(a count of how many times a given tone was present in the analysis), as well as "unique tones"(a string containing each unique tone name for this request). Please visit the usage section of this document for more information on what that request / response looks like.

This micro services uses the IBM Tone Analyzer API. Read the API documentation here

To view all the repositories associated with Vivid, please visit Vivid-Project

Built With


Getting Started

To properly use this application you will need to set up and configure three repositories. Follow the Configuration directions in each repository to get Vivd running locally! Alternatively, check out the production application [here](put front end heroku here)!!!

Prerequisites

These setup instructions are for Mac OS.

Install Necessary Programs

Be sure your machine has Python installed. Postman is required for sending requests and verifying API responses from the IBM Watson Tone Analyzer API.

Configuration

Setting Up this Microservice

  1. Clone this repo git clone git@github.com:Vivid-Project/microservice.git

  2. Enter the directory it was cloned into cd microservice

  3. Run pip install -r requirements.txt to install dependencies

  4. Go here and sign up for a free api key

  5. Run touch .env and in this file add your api key in this format: TONE_ANALYZER_API_KEY = 'your-key-here'


Endpoints

Quick Start

This microservice has a single end point. To quickly use this endpoint please direct requests to https://tone-analyzer-microservice.herokuapp.com/microservice/api/v1.0/tones (our deployed application).

It only needs to be given a raw text body in the request to generate a response. Punctuation is important, as this service will analyze the given input sentence by sentence. Alternatively, ensure each new sentence starts on a new line.

It should be noted that for this microservice to run optimally, it currently only accepts English or French. It is recommended that you use one or the other and not both if wanting to achieve the highest accuracy from the tone analyzer api.

This collection has been set up for you. One request is set up to run from our deployed heroku application, the other for if you are running locally!

Run in Postman

POST /microservice/api/v1.0/tones

Example raw text # 1:


There is no pain, you are receding. A distant ship, smoke on the horizon. You are only coming through in waves. Your lips move, but I can't hear what you're saying. When I was a child, I had a fever. My hands felt just like two balloons. Now I've got that feeling once again. I can't explain, you would not understand. This is not how I am.



Example raw text # 2(No Punctuation):


There is no pain, you are receding
A distant ship, smoke on the horizon
You are only coming through in waves
Your lips move, but I can't hear what you're saying
When I was a child, I had a fever
My hands felt just like two balloons
Now I've got that feeling once again
I can't explain, you would not understand
This is not how I am



Example Response:

{
    "tone_strength": {
        "Analytical": 2,
        "Joy": 1,
        "Tentative": 1
    },
    "unique_tones": "Analytical, Joy, Tentative"
}

For local use

After completing the configuration steps,

  1. In the command line run python run.py This will spin up your local server.

  2. Open up Postman and using a POST to localhost http://127.0.0.1:5000/microservice/api/v1.0/tones, include a raw text body and you are ready to go!


Testing

Pytest was used for the testing of this microservice.

To view the test coverage;

Once inside your terminal within the microservice directory run the following command.

coverage report

This will show you the quick summary of the test coverage in this application.

Alternatively, you can run coverage html to generate a folder containing a more detailed analysis of the coverage in this repository. Simply navigate to the full path of the file in your browser to view these reports.


Roadmap

See Open Issues or visit our Project Board for a list of proposed features, known issues, and project extensions.


Contributing

Contributions are what make this community such an amazing and fun place to learn, grow, and create! Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch git checkout -b feature/NewGreatFeature
  3. Commit your Changes git commit -m 'Add some NewGreatFeature'
  4. Push to the Branch git push origin feature/NewGreatFeature
  5. Open a new Pull Request!

## Contact

Amanda Davidson  - LinkedIn - GitHub - Turing Alum Profile

Shawn Truesdale    - LinkedIn - GitHub

Jonathan Wilson     - LinkedIn - GitHub - Turing Alum Profile

Zach Stearns           - LinkedIn - GitHub - Turing Alum Profile

Aidan Murray           - LinkedIn - GitHub

Taylor Phillips           - LinkedIn - GitHub - Turing Alum Profile

Project Link: Vivid

About

Micro-service for generating a tone analysis


Languages

Language:Python 99.4%Language:HTML 0.6%