|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
def text_summarize(text): |
|
pipe = pipeline("summarization", model="human-centered-summarization/financial-summarization-pegasus") |
|
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: ') |
|
|
|
|
|
st.text('Processing Finance News Summarization...') |
|
summary = text_summarize(text) |
|
st.write(summary) |
|
|
|
|
|
st.text('Processing Sentiment Analytics...') |
|
label = sentiment(summary) |
|
st.text('The sentiment of finance news is: ') |
|
st.write(label) |
|
|
|
if __name__ == "__main__": |
|
main() |