Spaces:
Sleeping
Sleeping
neuralworm
commited on
Commit
•
82d4320
1
Parent(s):
fec7d19
fix most frequent phrase
Browse files
app.py
CHANGED
@@ -195,33 +195,40 @@ with gr.Blocks() as app:
|
|
195 |
new_step = math.ceil(float_step * 2)
|
196 |
return new_step, float_step * 2
|
197 |
|
|
|
198 |
def perform_search(step, rounds_combination, tlang, strip_spaces, strip_in_braces, strip_diacritics_chk, merge_results, include_torah, include_bible, include_quran, gematria_text, date_words_output):
|
199 |
els_results = perform_els_search(step, rounds_combination, tlang, strip_spaces, strip_in_braces, strip_diacritics_chk, merge_results, include_torah, include_bible, include_quran)
|
200 |
|
201 |
# --- Network Search Integration ---
|
202 |
-
|
203 |
for result in els_results:
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
matching_phrases = search_gematria_in_db(gematria_sum, max_words)
|
|
|
|
|
207 |
most_frequent_phrase = get_most_frequent_phrase(matching_phrases)
|
208 |
|
209 |
-
# Add
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
})
|
217 |
-
|
218 |
-
# Create DataFrame
|
219 |
-
df = pd.DataFrame(df_data)
|
220 |
df.index = range(1, len(df) + 1)
|
221 |
df.reset_index(inplace=True)
|
222 |
df.rename(columns={'index': 'Result Number'}, inplace=True)
|
223 |
|
224 |
-
return df,
|
|
|
|
|
225 |
|
226 |
# --- Event Triggers ---
|
227 |
round_x.change(update_rounds_combination, inputs=[round_x, round_y], outputs=rounds_combination)
|
@@ -254,4 +261,4 @@ with gr.Blocks() as app:
|
|
254 |
)
|
255 |
|
256 |
if __name__ == "__main__":
|
257 |
-
app.launch(share=False)
|
|
|
195 |
new_step = math.ceil(float_step * 2)
|
196 |
return new_step, float_step * 2
|
197 |
|
198 |
+
|
199 |
def perform_search(step, rounds_combination, tlang, strip_spaces, strip_in_braces, strip_diacritics_chk, merge_results, include_torah, include_bible, include_quran, gematria_text, date_words_output):
|
200 |
els_results = perform_els_search(step, rounds_combination, tlang, strip_spaces, strip_in_braces, strip_diacritics_chk, merge_results, include_torah, include_bible, include_quran)
|
201 |
|
202 |
# --- Network Search Integration ---
|
203 |
+
updated_els_results = [] # List to store updated results with most frequent phrase
|
204 |
for result in els_results:
|
205 |
+
print("DEBUG: Result from perform_els_search:", result)
|
206 |
+
try:
|
207 |
+
gematria_sum = calculate_gematria(result['result_text'])
|
208 |
+
except KeyError as e:
|
209 |
+
print(f"DEBUG: KeyError - Key '{e.args[0]}' not found in result. Skipping this result.")
|
210 |
+
continue
|
211 |
+
|
212 |
+
max_words = len(result['result_text'].split())
|
213 |
matching_phrases = search_gematria_in_db(gematria_sum, max_words)
|
214 |
+
|
215 |
+
# Find most frequent phrase for this specific result
|
216 |
most_frequent_phrase = get_most_frequent_phrase(matching_phrases)
|
217 |
|
218 |
+
# Add most frequent phrase to the result dictionary
|
219 |
+
result['Most Frequent Phrase'] = most_frequent_phrase
|
220 |
+
|
221 |
+
updated_els_results.append(result) # Append updated result to the list
|
222 |
+
|
223 |
+
# --- Prepare Dataframe ---
|
224 |
+
df = pd.DataFrame(updated_els_results) # Create DataFrame from updated results
|
|
|
|
|
|
|
|
|
225 |
df.index = range(1, len(df) + 1)
|
226 |
df.reset_index(inplace=True)
|
227 |
df.rename(columns={'index': 'Result Number'}, inplace=True)
|
228 |
|
229 |
+
return df, most_frequent_phrase # Note: most_frequent_phrase here will be from the last iteration, but it's not used for the DataFrame
|
230 |
+
|
231 |
+
|
232 |
|
233 |
# --- Event Triggers ---
|
234 |
round_x.change(update_rounds_combination, inputs=[round_x, round_y], outputs=rounds_combination)
|
|
|
261 |
)
|
262 |
|
263 |
if __name__ == "__main__":
|
264 |
+
app.launch(share=False)
|