Learto commited on
Commit
a300fda
·
1 Parent(s): 83b86de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -36
app.py CHANGED
@@ -1,42 +1,22 @@
1
- # # ***** Finacial Sentiment Analysis App *****
2
- # # Team *** AI Supremo
3
- # # Author *** Lerato Chere
4
 
5
- # import streamlit as st
6
- # from transformers import pipeline
7
-
8
- # sentiment_pipeline = pipeline("sentiment-analysis")
9
-
10
- # st.title("Financial Sentiment Analysis \n Team AI Supremo ")
11
- # st.write("Enter a Financial Statement to Analyze the Sentiment:")
12
- # user_input = st.text_input("")
13
- # st.write("Press the Enter key")
14
-
15
- # if user_input:
16
- # result = sentiment_pipeline(user_input)
17
- # sentiment = result[0]["label"]
18
- # confidence = result[0]["score"]
19
-
20
- # st.write(f"Sentiment: {sentiment}")
21
- # st.write(f"Confidence: {confidence:.2%}")
22
-
23
-
24
-
25
- from transformers import BertTokenizer, BertForSequenceClassification
26
  from transformers import pipeline
27
 
28
- model = BertForSequenceClassification.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis",num_labels=3)
29
- tokenizer = BertTokenizer.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis")
 
 
 
 
30
 
31
- nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
 
 
 
32
 
33
- sentences = ["Operating profit rose to EUR 13.1 mn from EUR 8.7 mn in the corresponding period in 2007 representing 7.7 % of net sales.",
34
- "Bids or offers include at least 1,000 shares and the value of the shares must correspond to at least EUR 4,000.",
35
- "Raute reported a loss per share of EUR 0.86 for the first half of 2009 , against EPS of EUR 0.74 in the corresponding period of 2008.",
36
- ]
37
- results = nlp(sentences)
38
- print(results)
39
 
40
- [{'label': 'positive', 'score': 0.9998133778572083},
41
- {'label': 'neutral', 'score': 0.9997822642326355},
42
- {'label': 'negative', 'score': 0.9877365231513977}]
 
1
+ # ***** Finacial Sentiment Analysis App *****
2
+ # Team *** AI Supremo
3
+ # Author *** Lerato Chere
4
 
5
+ import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  from transformers import pipeline
7
 
8
+ sentiment_pipeline = pipeline("sentiment-analysis")
9
+
10
+ st.title("Financial Sentiment Analysis \n Team AI Supremo ")
11
+ st.write("Enter a Financial Statement to Analyze the Sentiment:")
12
+ user_input = st.text_input("")
13
+ st.write("Press the Enter key")
14
 
15
+ if user_input:
16
+ result = sentiment_pipeline(user_input)
17
+ sentiment = result[0]["label"]
18
+ confidence = result[0]["score"]
19
 
20
+ st.write(f"Sentiment: {sentiment}")
21
+ st.write(f"Confidence: {confidence:.2%}")
 
 
 
 
22