-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
26 lines (20 loc) · 826 Bytes
/
app.py
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
import streamlit as st
from sumapi.api import SumAPI
api = SumAPI(username='kave', password='kave')
def get_sentiment(text: str):
result = api.sentiment_analysis(text, domain='general')
return result['evaluation']['label']
def get_color(sentiment):
# Duygu analizine göre renk döndür
if sentiment == "Pozitif":
return "#A8E6CF" # Pastel Yeşil
elif sentiment == "Negatif":
return "#FF8A80" # Pastel Kırmızı
elif sentiment == "Nötr":
return "#FFD3B6" # Pastel Turuncu
st.title("SumAPI Duygu Analizi Uygulaması")
user_input = st.text_input("Bir şeyler yazın:")
if user_input:
sentiment = get_sentiment(user_input)
color = get_color(sentiment)
st.write(f'<div style="color: {color};">Duygu Analizi Sonucu: {sentiment}</div>', unsafe_allow_html=True)