Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
# txt2Story
|
7 |
+
def text_summarize(text):
|
8 |
+
pipe = pipeline("summarization", model="human-centered-summarization/financial-summarization-pegasus")
|
9 |
+
summary = pipe(text)[0]['summary_text']
|
10 |
+
print(summary)
|
11 |
+
return summary
|
12 |
+
|
13 |
+
# Story2Audio
|
14 |
+
def sentiment(story_text):
|
15 |
+
pipe = pipeline("text-classification", model="WillWEI0103/CustomModel_finance_sentiment_analytics")
|
16 |
+
label = pipe(story_text)[0]['label']
|
17 |
+
return label
|
18 |
+
|
19 |
+
|
20 |
+
def main(text):
|
21 |
+
st.set_page_config(page_title="Your Finance news", page_icon="📰")
|
22 |
+
st.header("Summarize Your Finance News and Analyze Sentiment")
|
23 |
+
text=st.text_input('Input your Finance news: ')
|
24 |
+
|
25 |
+
#Stage 1: Text Summarization
|
26 |
+
st.text('Processing Finance News Summarization...')
|
27 |
+
summary = text_summarize(text)
|
28 |
+
st.write(summary)
|
29 |
+
|
30 |
+
#Stage 2: Sentiment Analytics
|
31 |
+
st.text('Processing Sentiment Analytics...')
|
32 |
+
label = sentiment(summary)
|
33 |
+
st.text('The sentiment of finance news is: ')
|
34 |
+
st.write(label)
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
main()
|