Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Import streamlit and pipeline
|
2 |
+
import streamlit as st
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
|
6 |
+
pipe_sent = pipeline("text-classification", model="ProsusAI/finbert")
|
7 |
+
pipe_trans = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
|
8 |
+
|
9 |
+
# Streamlit application title
|
10 |
+
st.title("FinSentinel-Portuguese Financial Sentiment Analysis")
|
11 |
+
st.write("Classification for 3 attitudes: positive, netural, negative")
|
12 |
+
|
13 |
+
# Text input for user to enter the text to classify
|
14 |
+
text = st.text_area("Enter the text to classify", "")
|
15 |
+
|
16 |
+
# Perform text classification when the user clicks the "Classify" button
|
17 |
+
if st.button("Classify"):
|
18 |
+
# Perform text classification on the input text
|
19 |
+
results = pipe_sent(pipe_trans(text))[0]
|
20 |
+
|
21 |
+
# Display the classification result
|
22 |
+
max_score = float('-inf')
|
23 |
+
max_label = ''
|
24 |
+
max_score = result['score']
|
25 |
+
max_label = result['label']
|
26 |
+
|
27 |
+
st.write("Text:", text)
|
28 |
+
st.write("Label:", max_label)
|
29 |
+
st.write("Score:", max_score)
|