Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ CACHE_FILE = "tanakh_phrasedict.cache"
|
|
21 |
|
22 |
def get_power_result(total_sum: int, query_value: int) -> int:
|
23 |
"""Calculates the power or root result."""
|
24 |
-
if total_sum <=
|
25 |
return 1
|
26 |
if query_value <= total_sum:
|
27 |
try:
|
@@ -30,7 +30,11 @@ def get_power_result(total_sum: int, query_value: int) -> int:
|
|
30 |
except (ValueError, OverflowError):
|
31 |
return 1
|
32 |
else:
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
|
35 |
def find_all_matching_phrases(target_sum: int, phrase_dictionary: Dict[int, List[Dict]]) -> List[Dict]:
|
36 |
"""Finds all phrases matching a target Gematria."""
|
|
|
21 |
|
22 |
def get_power_result(total_sum: int, query_value: int) -> int:
|
23 |
"""Calculates the power or root result."""
|
24 |
+
if total_sum <= 1 or query_value <= 1:
|
25 |
return 1
|
26 |
if query_value <= total_sum:
|
27 |
try:
|
|
|
30 |
except (ValueError, OverflowError):
|
31 |
return 1
|
32 |
else:
|
33 |
+
try:
|
34 |
+
exponent = int(math.floor(math.log(query_value, total_sum)))
|
35 |
+
return total_sum ** exponent
|
36 |
+
except (ValueError, OverflowError):
|
37 |
+
return 1
|
38 |
|
39 |
def find_all_matching_phrases(target_sum: int, phrase_dictionary: Dict[int, List[Dict]]) -> List[Dict]:
|
40 |
"""Finds all phrases matching a target Gematria."""
|