Spaces:
Sleeping
Sleeping
neuralworm
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -78,7 +78,7 @@ def get_most_frequent_phrase(results):
|
|
78 |
phrase_counts = defaultdict(int)
|
79 |
for words, book, chapter, verse, phrase_length, word_position in results:
|
80 |
phrase_counts[words] += 1
|
81 |
-
most_frequent_phrase = max(phrase_counts, key=phrase_counts.get)
|
82 |
return most_frequent_phrase
|
83 |
|
84 |
# --- Functions from BOS app.py ---
|
@@ -198,23 +198,29 @@ with gr.Blocks() as app:
|
|
198 |
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)
|
199 |
|
200 |
# --- Network Search Integration ---
|
201 |
-
|
202 |
for result in els_results:
|
203 |
gematria_sum = calculate_gematria(result['match'])
|
204 |
max_words = len(result['match'].split())
|
205 |
matching_phrases = search_gematria_in_db(gematria_sum, max_words)
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
df.index = range(1, len(df) + 1)
|
213 |
df.reset_index(inplace=True)
|
214 |
df.rename(columns={'index': 'Result Number'}, inplace=True)
|
215 |
-
df['Most Frequent Phrase'] = most_frequent_phrase # Add new column
|
216 |
|
217 |
-
return df,
|
218 |
|
219 |
# --- Event Triggers ---
|
220 |
round_x.change(update_rounds_combination, inputs=[round_x, round_y], outputs=rounds_combination)
|
|
|
78 |
phrase_counts = defaultdict(int)
|
79 |
for words, book, chapter, verse, phrase_length, word_position in results:
|
80 |
phrase_counts[words] += 1
|
81 |
+
most_frequent_phrase = max(phrase_counts, key=phrase_counts.get) if phrase_counts else None # Handle empty results
|
82 |
return most_frequent_phrase
|
83 |
|
84 |
# --- Functions from BOS app.py ---
|
|
|
198 |
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)
|
199 |
|
200 |
# --- Network Search Integration ---
|
201 |
+
df_data = []
|
202 |
for result in els_results:
|
203 |
gematria_sum = calculate_gematria(result['match'])
|
204 |
max_words = len(result['match'].split())
|
205 |
matching_phrases = search_gematria_in_db(gematria_sum, max_words)
|
206 |
+
most_frequent_phrase = get_most_frequent_phrase(matching_phrases)
|
207 |
+
|
208 |
+
# Add data to the list for DataFrame creation
|
209 |
+
df_data.append({
|
210 |
+
'book': result['book'],
|
211 |
+
'chapter': result['chapter'],
|
212 |
+
'verse': result['verse'],
|
213 |
+
'match': result['match'],
|
214 |
+
'Most Frequent Phrase': most_frequent_phrase
|
215 |
+
})
|
216 |
+
|
217 |
+
# Create DataFrame
|
218 |
+
df = pd.DataFrame(df_data)
|
219 |
df.index = range(1, len(df) + 1)
|
220 |
df.reset_index(inplace=True)
|
221 |
df.rename(columns={'index': 'Result Number'}, inplace=True)
|
|
|
222 |
|
223 |
+
return df, df['Most Frequent Phrase'].iloc[0] if not df.empty else None
|
224 |
|
225 |
# --- Event Triggers ---
|
226 |
round_x.change(update_rounds_combination, inputs=[round_x, round_y], outputs=rounds_combination)
|