File size: 955 Bytes
05fd3dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Import streamlit and pipeline
import streamlit as st
from transformers import pipeline


pipe_sent = pipeline("text-classification", model="ProsusAI/finbert")
pipe_trans = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")

# Streamlit application title
st.title("FinSentinel-Portuguese Financial Sentiment Analysis")
st.write("Classification for 3 attitudes: positive, netural, negative")

# Text input for user to enter the text to classify
text = st.text_area("Enter the text to classify", "")

# Perform text classification when the user clicks the "Classify" button
if st.button("Classify"):
    # Perform text classification on the input text
    results = pipe_sent(pipe_trans(text))[0]

    # Display the classification result
    max_score = float('-inf')
    max_label = ''
    max_score = result['score']
    max_label = result['label']

    st.write("Text:", text)
    st.write("Label:", max_label)
    st.write("Score:", max_score)