Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ def load_summarize_pipeline(): # summarize_pipeline
|
|
49 |
return summarize_pipeline
|
50 |
|
51 |
|
52 |
-
def summarize_txt(summarize_pipeline, texts, length):
|
53 |
|
54 |
summary = summarize_pipeline(texts, max_length=10, num_return_sequences=1)
|
55 |
result = summary[0]["summary_text"]
|
@@ -105,8 +105,9 @@ st.write("Search Query:", search_query)
|
|
105 |
# Button to trigger scraping and summarize
|
106 |
if st.button("Scrape & Summarize"):
|
107 |
with st.spinner("Scraping..."):
|
108 |
-
|
109 |
progress_text = st.empty()
|
|
|
110 |
total_limit = 5000 # Maximum number of submissions to check
|
111 |
df = scrape_reddit_data(search_query, total_limit)
|
112 |
length = len(df)
|
@@ -115,7 +116,8 @@ if st.button("Scrape & Summarize"):
|
|
115 |
with st.spinner("Loading Summarizing Pipeline"):
|
116 |
summarize_pipeline = load_summarize_pipeline()
|
117 |
with st.spinner("Summarizing txt data..."):
|
118 |
-
df["Detail_Summary"] = df["Detail"].apply(lambda x:
|
|
|
119 |
|
120 |
st.session_state["df"] = df
|
121 |
|
@@ -129,9 +131,13 @@ if st.button("Sentiment Analysis"):
|
|
129 |
st.write("Sentiment pipeline loaded...")
|
130 |
|
131 |
with st.spinner("Doing Sentiment Analysis..."):
|
|
|
|
|
132 |
# title is short, so dont havwe to use batch processing
|
133 |
-
df['Title_Sentiment'] = df['Title'].apply(lambda x:
|
134 |
-
|
|
|
|
|
135 |
|
136 |
# # palarell procsssing for each row of detail
|
137 |
# with ThreadPoolExecutor() as executor:
|
|
|
49 |
return summarize_pipeline
|
50 |
|
51 |
|
52 |
+
def summarize_txt(summarize_pipeline, texts, length, progress_bar):
|
53 |
|
54 |
summary = summarize_pipeline(texts, max_length=10, num_return_sequences=1)
|
55 |
result = summary[0]["summary_text"]
|
|
|
105 |
# Button to trigger scraping and summarize
|
106 |
if st.button("Scrape & Summarize"):
|
107 |
with st.spinner("Scraping..."):
|
108 |
+
progress_bar = st.progress(0)
|
109 |
progress_text = st.empty()
|
110 |
+
|
111 |
total_limit = 5000 # Maximum number of submissions to check
|
112 |
df = scrape_reddit_data(search_query, total_limit)
|
113 |
length = len(df)
|
|
|
116 |
with st.spinner("Loading Summarizing Pipeline"):
|
117 |
summarize_pipeline = load_summarize_pipeline()
|
118 |
with st.spinner("Summarizing txt data..."):
|
119 |
+
df["Detail_Summary"] = df["Detail"].apply(lambda x: \
|
120 |
+
summarize_txt(summarize_pipeline, x, length, progress_bar) if x else None)
|
121 |
|
122 |
st.session_state["df"] = df
|
123 |
|
|
|
131 |
st.write("Sentiment pipeline loaded...")
|
132 |
|
133 |
with st.spinner("Doing Sentiment Analysis..."):
|
134 |
+
progress_bar = st.progress(0)
|
135 |
+
|
136 |
# title is short, so dont havwe to use batch processing
|
137 |
+
df['Title_Sentiment'] = df['Title'].apply(lambda x: \
|
138 |
+
safe_sentiment(sentiment_pipeline, preprocess_text(x), length, progress_bar) if x else None)
|
139 |
+
df['Detail_Sentiment'] = df['Detail_Summary'].apply(lambda x: \
|
140 |
+
safe_sentiment(sentiment_pipeline, preprocess_text(x), length, progress_bar) if x else None)
|
141 |
|
142 |
# # palarell procsssing for each row of detail
|
143 |
# with ThreadPoolExecutor() as executor:
|