Skip to content

API for performing sentiment analysis in portuguese sentences using NLP

License

Notifications You must be signed in to change notification settings

vncsmyrnk/sentiment-analysis-pt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python TensorFlow Keras
CI

Sentiment Analysis in Portuguese Sentences

API for performing sentiment analysis in portuguese sentences using NLP.

This project aims at analyzing and predicting sentiments associated with texts written in the Portuguese language through NLP. This initiative takes into account the absence of similar tools in this language, as much of the research and applications focus on the English language. Technically, it is an API that returns a sentiment analysis related to certain inputs. To do this, pretrained models and tools for working with tasks related to natural language processing are used.

This project is based on TensorFlow and Transformers for the NLP features and Flask for routing.

The NLP model used is distilbert-base-multilingual-cased-sentiments-student, available on the 🤗 Hugging Face Hub.

Run with Docker

docker build --tag sentiment-analysis-pt
docker run --rm -p 5000:5000 sentiment-analysis-pt

Development

docker build --target base --tag sentiment-analysis-pt-dev
docker run --rm -it -v "$(pwd)"/src:/var/app/ -p 5000:5000 sentiment-analysis-pt-dev bash
pip install -r requirements.txt --ignore-installed
flask --app app run --host 0.0.0.0

Use case

curl -X POST localhost:5000/analyze -H "Content-Type: application/json" -d '{"sentence": "O produto atendeu às minhas necessidades"}'

Example respose:

[
  [
    {
      "label": "positive",
      "score": 0.7563667297363281
    },
    {
      "label": "neutral",
      "score": 0.09914696961641312
    },
    {
      "label": "negative",
      "score": 0.1444862186908722
    }
  ]
]

Project steps

  • REST API minimal app
  • CI Pipeline
  • Integranting NLP sentiment classification
  • CD Pipeline
  • Developing custom NLP Model