import streamlit as st # Sentiment analysis function def analyze_sentiment(text, model): if model == "cardiffnlp/twitter-xlm-roberta-base-sentiment-multilingual": classifier = pipeline("sentiment-analysis", model=model) result = classifier(text)[0] sentiment = result['label'] score = result['score'] return sentiment, score # Buat button analyze yang melaukan perintah sebagai berikut if st.button("Analyze"): sentiment, score = analyze_sentiment(text, model) st.write(f"Sentiment: {sentiment}") if score is not None: st.write(f"Score: {score}")