|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
|
|
sentiment_pipeline = pipeline("sentiment-analysis", model="Walid-Ahmed/arabic-sentiment-model") |
|
|
|
|
|
|
|
label_map = { |
|
"LABEL_0": "Negative", |
|
"LABEL_1": "Positive" |
|
} |
|
|
|
|
|
def analyze_sentiment(text): |
|
result = sentiment_pipeline(text) |
|
|
|
label = result[0]['label'] |
|
score = result[0]['score'] |
|
return f"Sentiment: {label}, Confidence: {score:.2f}" |
|
|
|
|
|
interface = gr.Interface( |
|
fn=analyze_sentiment, |
|
inputs="text", |
|
outputs="text", |
|
title="Arabic Sentiment Analysis", |
|
description="Enter an Arabic sentence and get the sentiment (positive or negative).", |
|
examples=[["هذا المنتج رائع جدا"], ["هذا المنتج سيء للغاية"]] |
|
) |
|
|
|
|
|
interface.launch() |