File size: 750 Bytes
a235a65
 
 
9c4c6ac
 
 
 
 
a235a65
9c4c6ac
a235a65
9c4c6ac
 
 
 
 
 
 
 
 
a235a65
 
9c4c6ac
 
 
 
a235a65
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
from transformers import pipeline

# Modeli yükle
classifier = pipeline(
    "sentiment-analysis",
    model="saribasmetehan/bert-base-turkish-sentiment-analysis"
)

# Fonksiyon
def analyze_sentiment(text):
    result = classifier(text)[0]
    label_map = {
        "LABEL_0": "Nötr",
        "LABEL_1": "Pozitif",
        "LABEL_2": "Negatif"
    }
    return label_map.get(result['label'], result['label'])

# Gradio arayüzü
iface = gr.Interface(
    fn=analyze_sentiment,
    inputs=gr.Textbox(lines=3, placeholder="Metni buraya yazın..."),
    outputs="text",
    title="Türkçe Duygu Analizi",
    description="Bu uygulama verilen Türkçe metni Pozitif, Nötr veya Negatif olarak sınıflandırır."
)

iface.launch()