File size: 1,026 Bytes
05fd3dd
 
 
 
 
 
83d14c6
05fd3dd
 
 
 
 
 
 
 
 
 
 
574362f
83d14c6
05fd3dd
 
 
 
7814964
b40863c
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
30
#Import streamlit and pipeline
import streamlit as st
from transformers import pipeline


pipe_sent = pipeline("text-classification", model="ProsusAI/finbert")
pipe_tran = 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
    translated_text = pipe_tran(text)[0]['translation_text']
    results = pipe_sent(translated_text)[0]

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

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