|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def analyze_sentiment(text): |
|
sentiment_analyzer = pipeline("sentiment-analysis") |
|
result = sentiment_analyzer(text) |
|
return result[0]['label'], result[0]['score'] |
|
|
|
def main(): |
|
st.title("Financial Sentiment Analysis") |
|
|
|
|
|
text_input = st.text_area("Enter financial news or tweet:", "") |
|
|
|
if st.button("Analyze Sentiment"): |
|
if text_input: |
|
|
|
label, score = analyze_sentiment(text_input) |
|
|
|
|
|
st.write(f"Sentiment: {label}") |
|
st.write(f"Confidence Score: {score:.2%}") |
|
else: |
|
st.warning("Please enter some text for analysis.") |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|