| import streamlit as st |
| from transformers import pipeline |
|
|
| |
| classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment") |
|
|
| |
| st.title("Hugging Face Sentiment Analysis 🚀") |
|
|
| |
| user_input = st.text_area("Metni gir:") |
|
|
| |
| labels_dict = { |
| "LABEL_0": "Negatif", |
| "LABEL_1": "Nötr", |
| "LABEL_2": "Pozitif" |
| } |
|
|
| |
| if st.button("Analiz Et"): |
| if user_input: |
| result = classifier(user_input) |
| |
| |
| st.write(result) |
| if result: |
| label = result[0]['label'] |
| score = result[0]['score'] |
|
|
| |
| duygu = labels_dict.get(label, "Bilinmeyen") |
|
|
| st.write(f"📌 **Duygu:** {duygu}") |
| st.write(f"🔢 **Güven Skoru:** {score:.2f}") |
| else: |
| st.warning("Modelden sonuç alınamadı.") |
| else: |
| st.warning("Lütfen bir metin gir!") |
|
|