kusa04 commited on
Commit
c0edd3d
·
verified ·
1 Parent(s): 683ced8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
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
- # progress_bar = st.progress(0)
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: summarize_txt(summarize_pipeline, x, length) if x else None)
 
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: safe_sentiment(sentiment_pipeline, preprocess_text(x), length) if x else None)
134
- df['Detail_Sentiment'] = df['Detail_Summary'].apply(lambda x: safe_sentiment(sentiment_pipeline, preprocess_text(x), length) if x else None)
 
 
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: