Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.7 KB

File metadata and controls

58 lines (43 loc) · 1.7 KB

Sentiment Analysis

USING : Python, Fastapi, Pydantic, Transformer

A Backend build on Python & Fastapi with a RESTful API endpoint for sentiment analysis.
The API will accept text input, validate with Pydantic and return the sentiment analysis result using a pre-trained machine learning model.

Installation

Make sure python version >=3.9.
Clone this repo, open in terminal and

Run :

python -m venv .venv 

In Terminal, Run the following commands :

In Linux: source .venv/bin/activate

In Windows: .venv\Scripts\activate

Then install the required dependencies and start app

pip install  -r requirements.txt 
uvicorn main:app

What's in it ?

  • Minimal Static FrontEnd : http://127.0.0.1:8000/
    • Write an Sentence and Get Sentiment-Analyses instantly
  • Request is validated
  • Response is validated
  • Added Extra Query Sentiment Analysis (%)Percentage Result
  • Exception Handling included
API Routes

  • GET REQUEST - http://127.0.0.1:8000/hello
    • Request Payload - Empty
    • Expected Response - "Hello World"
  • POST REQUEST http://127.0.0.1:8000/analyze
    • Request Payload - JSON : {"text": "STRING"}
    • Expected Response - JSON : {"sentiment":"positive/negative/neutral"}
    • To get a Response with Sentence Sentiment and Score add ?withScore=True
      i.e. - POST REQUEST http://127.0.0.1:8000/analyze?withScore=True
    • With Score Expected Response - JSON : {"sentiment":"positive/negative/neutral", "score": float}