WillWEI0103's picture
Update app.py
9f1e9e2 verified
raw
history blame
1.3 kB
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 = text_summarize(text)[0]['summary_text']
return summary
def sentiment(summary):
pipe = pipeline("text-classification", model="WillWEI0103/CustomModel_finance_sentiment_analytics")
label = pipe(summary)[0]['label']
return label
def main():
dicts={"bullish":'Positive',"bearish":'Negative','neutral':"Neutral"}
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)
if isinstance(text,str):
st.text('Your Finance news: ')
st.write(str(text))
#Stage 1: Text Summarization
st.text('Processing Finance News Summarization...')
summary=text_summarize(text)
st.write(summary)
#Stage 2: Sentiment Analytics
st.text('Processing Sentiment Analytics...')
label = sentiment(summary)
label=dicts[label]
st.text('The sentiment of finance news is: ')
st.write(label)
if __name__ == "__main__":
main()