Spaces:
Running
Running
neuralworm
commited on
Commit
·
a676448
1
Parent(s):
ebaddfd
initial commit
Browse files- app.py +21 -10
- requirements.txt +0 -6
app.py
CHANGED
@@ -3,8 +3,8 @@ logger = logging.getLogger(__name__)
|
|
3 |
logging.basicConfig(level=logging.INFO)
|
4 |
|
5 |
import gradio as gr
|
6 |
-
from gradio_calendar import Calendar
|
7 |
-
from utils import date_to_words
|
8 |
from gematria import calculate_gematria, strip_diacritics
|
9 |
from datetime import datetime, timedelta
|
10 |
import json
|
@@ -17,14 +17,23 @@ def calculate_gematria_sum(text):
|
|
17 |
else:
|
18 |
return None
|
19 |
|
20 |
-
def perform_gematria_calculation_for_date_range(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
results = {}
|
22 |
delta = timedelta(days=1)
|
23 |
current_date = start_date
|
24 |
|
25 |
while current_date <= end_date:
|
26 |
-
date_words = date_to_words(current_date
|
|
|
27 |
gematria_sum = calculate_gematria_sum(date_words)
|
|
|
28 |
|
29 |
if gematria_sum not in results:
|
30 |
results[gematria_sum] = []
|
@@ -51,16 +60,18 @@ def generate_json_output(results, start_date, end_date):
|
|
51 |
# --- Main Gradio App ---
|
52 |
with gr.Blocks() as app:
|
53 |
with gr.Row():
|
54 |
-
start_date = Calendar(type="
|
55 |
-
end_date = Calendar(type="
|
56 |
|
57 |
calculate_btn = gr.Button("Calculate Gematria for Date Range")
|
58 |
json_output = gr.Textbox(label="JSON Output")
|
59 |
|
60 |
# --- Event Handlers ---
|
61 |
-
def perform_calculation(
|
62 |
-
|
63 |
-
|
|
|
|
|
64 |
return json_result
|
65 |
|
66 |
# --- Event Triggers ---
|
@@ -71,4 +82,4 @@ with gr.Blocks() as app:
|
|
71 |
)
|
72 |
|
73 |
if __name__ == "__main__":
|
74 |
-
app.launch(share=False)
|
|
|
3 |
logging.basicConfig(level=logging.INFO)
|
4 |
|
5 |
import gradio as gr
|
6 |
+
from gradio_calendar import Calendar
|
7 |
+
from utils import date_to_words # Annahme: utils.py enthält die date_to_words Funktion
|
8 |
from gematria import calculate_gematria, strip_diacritics
|
9 |
from datetime import datetime, timedelta
|
10 |
import json
|
|
|
17 |
else:
|
18 |
return None
|
19 |
|
20 |
+
def perform_gematria_calculation_for_date_range(start_date_str, end_date_str):
|
21 |
+
logger.info(f"Startdatum (String): {start_date_str}, Enddatum (String): {end_date_str}") # Debugging-Ausgabe
|
22 |
+
|
23 |
+
# Konvertiere die Datumsstrings in datetime-Objekte
|
24 |
+
start_date = datetime.strptime(start_date_str, "%Y-%m-%d")
|
25 |
+
end_date = datetime.strptime(end_date_str, "%Y-%m-%d")
|
26 |
+
|
27 |
+
logger.info(f"Startdatum: {start_date}, Enddatum: {end_date}") # Debugging-Ausgabe
|
28 |
results = {}
|
29 |
delta = timedelta(days=1)
|
30 |
current_date = start_date
|
31 |
|
32 |
while current_date <= end_date:
|
33 |
+
date_words = date_to_words(current_date)
|
34 |
+
logger.info(f"Datum: {current_date}, Tagesnamen: {date_words}") # Debugging-Ausgabe
|
35 |
gematria_sum = calculate_gematria_sum(date_words)
|
36 |
+
logger.info(f"Gematria-Summe: {gematria_sum}") # Debugging-Ausgabe
|
37 |
|
38 |
if gematria_sum not in results:
|
39 |
results[gematria_sum] = []
|
|
|
60 |
# --- Main Gradio App ---
|
61 |
with gr.Blocks() as app:
|
62 |
with gr.Row():
|
63 |
+
start_date = Calendar(type="date", label="Start Date") # Ändere den Typ zu "date"
|
64 |
+
end_date = Calendar(type="date", label="End Date") # Ändere den Typ zu "date"
|
65 |
|
66 |
calculate_btn = gr.Button("Calculate Gematria for Date Range")
|
67 |
json_output = gr.Textbox(label="JSON Output")
|
68 |
|
69 |
# --- Event Handlers ---
|
70 |
+
def perform_calculation(start_date_str, end_date_str): # Empfange Datumsstrings
|
71 |
+
logger.info("Berechnung gestartet") # Debugging-Ausgabe
|
72 |
+
results = perform_gematria_calculation_for_date_range(start_date_str, end_date_str)
|
73 |
+
json_result = generate_json_output(results, datetime.strptime(start_date_str, "%Y-%m-%d"), datetime.strptime(end_date_str, "%Y-%m-%d"))
|
74 |
+
logger.info("Berechnung abgeschlossen") # Debugging-Ausgabe
|
75 |
return json_result
|
76 |
|
77 |
# --- Event Triggers ---
|
|
|
82 |
)
|
83 |
|
84 |
if __name__ == "__main__":
|
85 |
+
app.launch(share=False)
|
requirements.txt
CHANGED
@@ -1,8 +1,2 @@
|
|
1 |
gradio==4.31.0
|
2 |
-
deep_translator==1.11.4
|
3 |
-
tabulate==0.9.0
|
4 |
gradio_calendar==0.0.4
|
5 |
-
inflect==7.2.1
|
6 |
-
fuzzywuzzy==0.18.0
|
7 |
-
python-Levenshtein==0.25.1
|
8 |
-
transliterate
|
|
|
1 |
gradio==4.31.0
|
|
|
|
|
2 |
gradio_calendar==0.0.4
|
|
|
|
|
|
|
|