samet214 commited on
Commit
d474703
·
verified ·
1 Parent(s): e2671e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -1,27 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
-
5
- # Bu model, 'savasy' adlı bir kullanıcı tarafından eğitilip paylaşılmış onun paylaştığı modeli yapay zeka ile biraz daha düzelttik.
6
  model_name = "savasy/bert-base-turkish-sentiment-cased"
7
  sentiment_analyzer = pipeline("sentiment-analysis", model=model_name)
8
 
9
- # Gelen metni analiz edecek ve sonucu bize uygun formatta geri döndürecek fonksiyon
10
  def analyze_sentiment(text):
11
  result = sentiment_analyzer(text)[0]
12
-
13
- label_map = {'positive': 'positive', 'negative': 'negative', 'neutral': 'neutral'}
14
- simple_label = label_map.get(result['label'], 'unknown')
15
-
16
- return {"sentiment": simple_label, "score": result['score']}
17
 
18
- # Gradio ile bu fonksiyondan bir web arayüzü ve API oluşturuyoruz.
19
  iface = gr.Interface(
20
  fn=analyze_sentiment,
21
  inputs=gr.Textbox(lines=2, placeholder="Analiz edilecek metni buraya girin..."),
22
  outputs="json",
23
- title="Duygu Analizi Servisi",
24
- description="Girilen Türkçe metnin duygu (pozitif, negatif, nötr) analizini yapar."
25
  )
26
 
27
- iface.launch(queue_enabled=False)
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
 
4
  model_name = "savasy/bert-base-turkish-sentiment-cased"
5
  sentiment_analyzer = pipeline("sentiment-analysis", model=model_name)
6
 
 
7
  def analyze_sentiment(text):
8
  result = sentiment_analyzer(text)[0]
9
+ return {"sentiment": result['label'], "score": result['score']}
 
 
 
 
10
 
 
11
  iface = gr.Interface(
12
  fn=analyze_sentiment,
13
  inputs=gr.Textbox(lines=2, placeholder="Analiz edilecek metni buraya girin..."),
14
  outputs="json",
15
+ title="Duygu Analizi Servisi"
 
16
  )
17
 
18
+
19
+ iface.launch()