This repository contains a Flask-based REST API for Arabic sentiment analysis using Arabert model, Dockerized for easy deployment.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Docker installed on your local machine. You can download Docker here.
- download model folder from here, uncompress it and put it in the your folder
- Your folder should be like this:
- arabic-sentiment-analysis-API (the main directory)
- --> app.py
- --> dockerfile
- --> requirements.txt
- --> arabert-model-v5-with-mixed
open command line then write these commands
cd <your-folder-path>
docker build --tag sentiment_analysis_ar .
wait unti it finishes, It may take many minutes
Run the Docker container,
docker run -p 4000:5000 sentiment_analysis_ar
The API should now be running and accessible locally at http://localhost:4000.
You can use tish command:
curl -i -X POST http://127.0.0.1:4000/predict -H "Content-Type: application/json" -d "{\"text\": \"الخدمة مو حلوة\"}"
- Method: POST
- Content-Type: application/json
- Input: JSON object with a text field containing the Arabic text for sentiment analysis.
- Output: JSON object with a prediction field containing the predicted sentiment (Positive, Neutral, or Negative).
Write your sentence in a command like this:
curl -X POST http://localhost:5000/predict -H 'Content-Type: application/json' -d '{"text":"المنتج حقكم مرة حلو!"}'
You get a response like this:
{
"prediction": "Positive"
}