Python
0
0 commits
updated Jun 12, 2025
This project provides a Flask-based REST API for analyzing sentiment in Arabic text. It can analyze individual messages, batch texts, and entire conversations, providing detailed sentiment analysis including negativity percentages.
⚠️ Important: The model files are not included in this repository due to size limitations. You can:
python fine_tune.py
git clone [repository-url]
cd [repository-name]
Download and place the model files as described in the Model Files section.
Install the required dependencies:
pip install -r requirements.txt
Start the server by running:
python app.py
The API will be available at http://localhost:5000
Analyze the sentiment of a single text.
Endpoint: POST /analyze
Request Body:
{
"text": "هذا المنتج رائع جداً"
}
Response:
{
"text": "هذا المنتج رائع جداً",
"sentiment": "positive",
"confidence": "95.5%"
}
Analyze multiple texts at once.
Endpoint: POST /analyze_batch
Request Body:
{
"texts": [
"هذا المنتج رائع جداً",
"لم يعجبني هذا المنتج على الإطلاق"
]
}
Analyze a complete conversation with role-based sentiment tracking.
Endpoint: POST /analyze_conversation
Request Body:
{
"conversation": "Customer: المنتج الذي استلمته لا يعمل بشكل صحيح\nAgent: عذراً جداً على هذه التجربة\nCustomer: حسناً، شكراً لك"
}
Response:
{
"overall_sentiment": "negative",
"negative_messages": [
{
"message": "المنتج الذي استلمته لا يعمل بشكل صحيح",
"confidence": "85.5%"
}
],
"sentiment_distribution": {
"positive": 0,
"neutral": 2,
"negative": 1
},
"negativity_percentage": "33.3%"
}
sentiment: Can be "positive", "neutral", or "negative"confidence: Confidence score of the predictionoverall_sentiment: Overall conversation sentimentnegative_messages: List of detected negative messagessentiment_distribution: Count of different sentiments in the conversationnegativity_percentage: Percentage of negative messages in the conversationThe API returns appropriate HTTP status codes:
The application is built using:
Python
0
0 commits
updated Jun 12, 2025
This project provides a Flask-based REST API for analyzing sentiment in Arabic text. It can analyze individual messages, batch texts, and entire conversations, providing detailed sentiment analysis including negativity percentages.
⚠️ Important: The model files are not included in this repository due to size limitations. You can:
python fine_tune.py
git clone [repository-url]
cd [repository-name]
Download and place the model files as described in the Model Files section.
Install the required dependencies:
pip install -r requirements.txt
Start the server by running:
python app.py
The API will be available at http://localhost:5000
Analyze the sentiment of a single text.
Endpoint: POST /analyze
Request Body:
{
"text": "هذا المنتج رائع جداً"
}
Response:
{
"text": "هذا المنتج رائع جداً",
"sentiment": "positive",
"confidence": "95.5%"
}
Analyze multiple texts at once.
Endpoint: POST /analyze_batch
Request Body:
{
"texts": [
"هذا المنتج رائع جداً",
"لم يعجبني هذا المنتج على الإطلاق"
]
}
Analyze a complete conversation with role-based sentiment tracking.
Endpoint: POST /analyze_conversation
Request Body:
{
"conversation": "Customer: المنتج الذي استلمته لا يعمل بشكل صحيح\nAgent: عذراً جداً على هذه التجربة\nCustomer: حسناً، شكراً لك"
}
Response:
{
"overall_sentiment": "negative",
"negative_messages": [
{
"message": "المنتج الذي استلمته لا يعمل بشكل صحيح",
"confidence": "85.5%"
}
],
"sentiment_distribution": {
"positive": 0,
"neutral": 2,
"negative": 1
},
"negativity_percentage": "33.3%"
}
sentiment: Can be "positive", "neutral", or "negative"confidence: Confidence score of the predictionoverall_sentiment: Overall conversation sentimentnegative_messages: List of detected negative messagessentiment_distribution: Count of different sentiments in the conversationnegativity_percentage: Percentage of negative messages in the conversationThe API returns appropriate HTTP status codes:
The application is built using: