File size: 504 Bytes
1d60fc4
c332a82
1d60fc4
 
 
 
 
 
c332a82
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import streamlit as st
from transformers import pipeline

st.title("Stock News Sentiment Analysis")
st.write("Enter some news text to analyze its sentiment:")

text = st.text_area("Text Input")
if text:
    try:
        # Load the sentiment analysis pipeline
        sentiment_pipeline = pipeline("sentiment-analysis")
        result = sentiment_pipeline(text)[0]
        st.write(f"Sentiment: {result['label']}, Score: {result['score']:.2f}")
    except Exception as e:
        st.error(f"Error: {e}")