Skip to content

Latest commit

 

History

History
90 lines (61 loc) · 2.43 KB

API_readme.md

File metadata and controls

90 lines (61 loc) · 2.43 KB

Arabic Sentiment Analysis API with Arabert Model

This repository contains a Flask-based REST API for Arabic sentiment analysis using Arabert model, Dockerized for easy deployment.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • 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

Build the Docker Image

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

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\": \"الخدمة مو حلوة\"}"

API Usage

Endpoint ( /predict )

  • 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"
}