portfolio_skill / app.py
jonathan-barrios
updated challenge code
8d5ce45
raw
history blame contribute delete
751 Bytes
import streamlit as st
from transformers import pipeline
def analyze_sentiment(text):
sentiment_pipe = pipeline("sentiment-analysis")
result = sentiment_pipe(text)
return result
def main():
st.title("Sentiment Analysis App")
st.write("Enter text for sentiment analysis πŸ‘ πŸ‘Ž")
text = st.text_area("Text input")
if st.button("Analyze Sentiment"):
if text:
sentiment_result = analyze_sentiment(text)
sentiment_label = sentiment_result[0]['label']
sentiment_score = sentiment_result[0]['score']
st.write("Sentiment:", sentiment_label)
st.write("Confidence Score:", sentiment_score)
if __name__ == "__main__":
main()