Upload 2 files
Browse files- app.py +27 -7
- requirements.txt +3 -0
app.py
CHANGED
|
@@ -1,7 +1,27 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Hugging Face'den Türkçe Sentiment Analysis Pipeline Yükleme
|
| 5 |
+
sentiment_pipeline = pipeline(
|
| 6 |
+
"sentiment-analysis",
|
| 7 |
+
model="savasy/bert-base-turkish-sentiment-cased"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
# Analiz Fonksiyonu
|
| 11 |
+
def analyze_sentiment(text):
|
| 12 |
+
result = sentiment_pipeline(text)
|
| 13 |
+
label = result[0]['label'] # Pozitif/Negatif
|
| 14 |
+
score = result[0]['score'] # Güven skoru
|
| 15 |
+
return f"Duygu: {label}, Güven Skoru: {score:.2f}"
|
| 16 |
+
|
| 17 |
+
# Gradio Arayüzü
|
| 18 |
+
interface = gr.Interface(
|
| 19 |
+
fn=analyze_sentiment,
|
| 20 |
+
inputs="text",
|
| 21 |
+
outputs="text",
|
| 22 |
+
title="Türkçe Duygu Analizi",
|
| 23 |
+
description="Bir cümle girin ve Türkçe duygu analizini yapın (Pozitif, Negatif, Nötr)."
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Uygulamayı Başlat
|
| 27 |
+
interface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|
| 3 |
+
gradio
|