neuralworm commited on
Commit
e261f72
·
1 Parent(s): 33e17d9
Files changed (3) hide show
  1. README.md +2 -2
  2. app.py +17 -16
  3. els_cache.db +1 -1
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Daily Psalm
3
  emoji: 🌍
4
  colorFrom: blue
5
  colorTo: gray
@@ -9,4 +9,4 @@ app_file: app.py
9
  pinned: false
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Daily Psalm Finder
3
  emoji: 🌍
4
  colorFrom: blue
5
  colorTo: gray
 
9
  pinned: false
10
  ---
11
 
12
+ This application finds daily Psalms based by date and name (optional).
app.py CHANGED
@@ -5,9 +5,9 @@ import re
5
  from datetime import datetime
6
  import hashlib
7
  import json
 
8
 
9
  import gradio as gr
10
- from deep_translator import GoogleTranslator
11
 
12
  import torah # Assuming you have your torah module
13
  from utils import date_to_words, custom_normalize
@@ -24,11 +24,7 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %
24
  DATABASE_FILE = 'gematria.db'
25
  ELS_CACHE_DB = 'els_cache.db'
26
  DATABASE_TIMEOUT = 60
27
-
28
- # --- Translator Initialization ---
29
- translator = GoogleTranslator(source='auto', target='en')
30
- LANGUAGES_SUPPORTED = translator.get_supported_languages(as_dict=True)
31
- LANGUAGE_CODE_MAP = LANGUAGES_SUPPORTED
32
 
33
 
34
  # --- Helper Functions ---
@@ -184,21 +180,20 @@ def create_biblegateway_iframe(book_name, chapter, verse):
184
  # --- Gradio Interface ---
185
 
186
  with gr.Blocks() as app:
187
- gr.Markdown("# Psalm Finder from ELS and Gematria")
188
  with gr.Row():
189
- name_input = gr.Textbox(label="Name")
190
  date_input = Calendar(label="Date", type="date")
 
 
191
  with gr.Row():
192
  run_button = gr.Button("Find Psalm")
193
  with gr.Row():
194
  iframe_output = gr.HTML(label="Psalm Display")
195
 
196
- def main_function(name, date):
197
- logger.debug(f"Entering main_function with name: '{name}', date: '{date}'")
198
 
199
- if not name or not date:
200
- logger.debug("Name or date missing. Returning error message.")
201
- return "Please enter both a name and a date."
202
  if isinstance(date, str):
203
  date = datetime.strptime(date, "%Y-%m-%d")
204
  logger.debug(f"Converted date string to datetime: {date}")
@@ -208,7 +203,6 @@ with gr.Blocks() as app:
208
  date_words = date_to_words(date_str)
209
  logger.debug(f"Date words: {date_words}")
210
 
211
-
212
  initial_gematria_sum = calculate_gematria_sum(name, date_words)
213
  logger.debug(f"Initial Gematria Sum: {initial_gematria_sum}")
214
 
@@ -216,7 +210,14 @@ with gr.Blocks() as app:
216
  logger.debug("Initial Gematria sum is None. Returning error message.")
217
  return "Could not calculate initial Gematria sum."
218
 
219
- els_result = get_first_els_result_genesis(initial_gematria_sum)
 
 
 
 
 
 
 
220
  if not els_result:
221
  logger.debug("No ELS result. Returning error message.")
222
  return "No ELS result found in Genesis."
@@ -238,7 +239,7 @@ with gr.Blocks() as app:
238
 
239
  run_button.click(
240
  main_function,
241
- inputs=[name_input, date_input],
242
  outputs=[iframe_output]
243
  )
244
 
 
5
  from datetime import datetime
6
  import hashlib
7
  import json
8
+ import math
9
 
10
  import gradio as gr
 
11
 
12
  import torah # Assuming you have your torah module
13
  from utils import date_to_words, custom_normalize
 
24
  DATABASE_FILE = 'gematria.db'
25
  ELS_CACHE_DB = 'els_cache.db'
26
  DATABASE_TIMEOUT = 60
27
+ ADJUSTMENT_CONSTANT = 137.035999177 # Use the more precise constant
 
 
 
 
28
 
29
 
30
  # --- Helper Functions ---
 
180
  # --- Gradio Interface ---
181
 
182
  with gr.Blocks() as app:
183
+ gr.Markdown("# Daily Psalm Finder")
184
  with gr.Row():
185
+ name_input = gr.Textbox(label="Name (optional)")
186
  date_input = Calendar(label="Date", type="date")
187
+ with gr.Row():
188
+ adjusted_sum_check = gr.Checkbox(label="Journal Sum + (Journal Sum / 137)", value=False)
189
  with gr.Row():
190
  run_button = gr.Button("Find Psalm")
191
  with gr.Row():
192
  iframe_output = gr.HTML(label="Psalm Display")
193
 
194
+ def main_function(name, date, adjusted_sum_check):
195
+ logger.debug(f"Entering main_function with name: '{name}', date: '{date}', adjusted_sum: {adjusted_sum_check}")
196
 
 
 
 
197
  if isinstance(date, str):
198
  date = datetime.strptime(date, "%Y-%m-%d")
199
  logger.debug(f"Converted date string to datetime: {date}")
 
203
  date_words = date_to_words(date_str)
204
  logger.debug(f"Date words: {date_words}")
205
 
 
206
  initial_gematria_sum = calculate_gematria_sum(name, date_words)
207
  logger.debug(f"Initial Gematria Sum: {initial_gematria_sum}")
208
 
 
210
  logger.debug("Initial Gematria sum is None. Returning error message.")
211
  return "Could not calculate initial Gematria sum."
212
 
213
+ # Adjust gematria sum if checkbox is checked
214
+ if adjusted_sum_check:
215
+ adjusted_sum = initial_gematria_sum + (initial_gematria_sum / ADJUSTMENT_CONSTANT)
216
+ initial_gematria_sum = math.ceil(adjusted_sum) # Use the adjusted sum
217
+ logger.debug(f"Adjusted Gematria Sum (using formula): {initial_gematria_sum}")
218
+
219
+
220
+ els_result = get_first_els_result_genesis(initial_gematria_sum, tlang='en') # Use adjusted sum here, and set target language to en
221
  if not els_result:
222
  logger.debug("No ELS result. Returning error message.")
223
  return "No ELS result found in Genesis."
 
239
 
240
  run_button.click(
241
  main_function,
242
+ inputs=[name_input, date_input, adjusted_sum_check],
243
  outputs=[iframe_output]
244
  )
245
 
els_cache.db CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e8cf8945d142c0a1dc7bc49db6d9e572189ed7fec91fa0cafe6618da724609b6
3
  size 12288
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:808e67a00d62be6d22c9b86b3137434c4fdd53a86f58aa94e44a4b5aac4b9a9f
3
  size 12288