Update functions.py
Browse files- functions.py +13 -0
functions.py
CHANGED
@@ -84,6 +84,19 @@ def sentiment_pipe(earnings_text):
|
|
84 |
|
85 |
return earnings_sentiment, earnings_sentences
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
@st.experimental_memo(suppress_st_warning=True)
|
88 |
def clean_text(text):
|
89 |
'''Clean all text'''
|
|
|
84 |
|
85 |
return earnings_sentiment, earnings_sentences
|
86 |
|
87 |
+
@st.experimental_memo(suppress_st_warning=True)
|
88 |
+
def summarize_text(text_to_summarize,max_len,min_len):
|
89 |
+
'''Summarize text with HF model'''
|
90 |
+
|
91 |
+
summarized_text = sum_pipe(text_to_summarize,max_length=max_len,min_length=min_len,clean_up_tokenization_spaces=True,no_repeat_ngram_size=4,
|
92 |
+
encoder_no_repeat_ngram_size=3,
|
93 |
+
repetition_penalty=3.5,
|
94 |
+
num_beams=4,
|
95 |
+
early_stopping=True)
|
96 |
+
summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
|
97 |
+
|
98 |
+
return summarized_text
|
99 |
+
|
100 |
@st.experimental_memo(suppress_st_warning=True)
|
101 |
def clean_text(text):
|
102 |
'''Clean all text'''
|