Skip to content

chapimenge3/Sentiserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentiserver

Sentinel - Real-time Sentiment Analysis for Social Media Posts using AWS Serverless Stack

This project is for analyzing post(or any text) using AWS Comprehend.

Demo

Watch the demo on Vimeo or click here.

Sentiserver.Demo.webm

Architecture

Architecture

Usage

Endpoints

POST /feed

This endpoint is for analyzing post(or any text) using AWS Comprehend.

Body:

{
  "text": "This is a sample text"
}

Response:

{
  "status": "pending",
  "timestamp": "2021-01-01T00:00:00.000Z",
  "updated_at": "2021-01-01T00:00:00.000Z",
  "sentiment": "NEUTRAL",
  "sentimentScore": {
    "positive": 0.0,
    "negative": 0.0,
    "neutral": 1.0,
    "mixed": 0.0
  }
}

GET /sentiment?id={id}

This endpoint is for getting the result of the analysis. You might need to wait for a while until the analysis is done.

Response:

{
  "status": "done",
  "timestamp": "2021-01-01T00:00:00.000Z",
  "updated_at": "2021-01-01T00:00:00.000Z",
  "sentiment": "NEUTRAL",
  "sentimentScore": {
    "positive": 0.0,
    "negative": 0.0,
    "neutral": 1.0,
    "mixed": 0.0
  }
}

Deployment

Prerequisites

Build

To deploy the first step is to build the project:

cd sentiserver
sam build

After running the above command you should see a .aws-sam folder in the sentiserver directory.

Deploy

To deploy the application in your AWS account, run the following command:

sam deploy

After a successful deployment, you should see the output in the terminal. Grab the API Gateway endpoint and use it to make requests to the API.

Example

Request

import requests

url = "https://xxxxxxxxxx.execute-api.ap-northeast-2.amazonaws.com/Prod/feed"
body = {
    "text": "You are the best!"
}

response = requests.post(url, json=body)
print(response.json())

Grab the id from the response. Wait a few seconds and then run the following code.

import requests

url = "https://xxxxxxxxxx.execute-api.ap-northeast-2.amazonaws.com/Prod/sentiment?id={}".format(id)

response = requests.get(url)

print(response.json())

You will see the result by now.

About

Sentinel - Real-time Sentiment Analysis for Social Media Posts using AWS Serverless Stack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages