File size: 1,141 Bytes
6e7d6b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40ed671
 
6e7d6b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
import streamlit as st
from transformers import pipeline

def text_summarize(text):
    pipe = pipeline("summarization", model="nickmuchi/fb-bart-large-finetuned-trade-the-event-finance-summarizer")
    summary = pipe(text)[0]['summary_text']
    print(summary)
    return summary

def sentiment(summary):
    pipe = pipeline("text-classification", model="WillWEI0103/CustomModel_finance_sentiment_analytics")
    label = pipe(summary)[0]['label']
    return label


def main():
    st.set_page_config(page_title="Your Finance news", page_icon="📰")
    st.header("Summarize Your Finance News and Analyze Sentiment")
    text=st.text_input('Input your Finance news(Max lenth<=3000): ',max_chars=3000)
    
    st.text('Your Finance news: ')
    st.write(str(text))
    
    #Stage 1: Text Summarization
    summary = text_summarize(text)
    st.text('Processing Finance News Summarization...')
    st.write(summary)

    #Stage 2: Sentiment Analytics
    st.text('Processing Sentiment Analytics...')
    label = sentiment(summary)
    st.text('The sentiment of finance news is: ')
    st.write(label)

if __name__ == "__main__":
    main()