Spaces:
Runtime error
Runtime error
bartman081523
commited on
Commit
•
612ea81
1
Parent(s):
2412db3
- app.py +34 -3
- c.txt +68 -0
- requirements.txt +2 -0
app.py
CHANGED
@@ -94,6 +94,28 @@ def download_json_file(config_json, step, rounds, strip_spaces, strip_in_braces,
|
|
94 |
logger.info(f"Downloaded JSON file to: {file_path}")
|
95 |
return file_path
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
# --- UI Components ---
|
98 |
|
99 |
with gr.Blocks() as app:
|
@@ -136,12 +158,20 @@ with gr.Blocks() as app:
|
|
136 |
json_download_btn = gr.Button("Prepare .json for Download")
|
137 |
json_file = gr.File(label="Download Config JSON", file_count="single")
|
138 |
|
139 |
-
# ---
|
|
|
|
|
|
|
|
|
140 |
|
141 |
def calculate_journal_sum(text, date_words):
|
142 |
"""Calculates the journal sum and updates the step value."""
|
|
|
|
|
|
|
|
|
143 |
sum_value = calculate_gematria_sum(text, date_words)
|
144 |
-
return sum_value, sum_value, sum_value
|
145 |
|
146 |
def update_step_half(float_step):
|
147 |
"""Updates the step value to half."""
|
@@ -153,6 +183,7 @@ with gr.Blocks() as app:
|
|
153 |
new_step = math.ceil(float_step * 2)
|
154 |
return new_step, float_step * 2
|
155 |
|
|
|
156 |
def handle_json_download(config_json, step, rounds, strip_spaces, strip_in_braces, strip_diacritics_chk):
|
157 |
"""Handles the download of the JSON config file."""
|
158 |
return download_json_file(config_json, step, rounds, strip_spaces, strip_in_braces, strip_diacritics_chk)
|
@@ -173,7 +204,7 @@ with gr.Blocks() as app:
|
|
173 |
gematria_btn.click(
|
174 |
calculate_journal_sum,
|
175 |
inputs=[gematria_text, date_words_output],
|
176 |
-
outputs=[gematria_result, step, float_step]
|
177 |
)
|
178 |
|
179 |
half_step_btn.click(
|
|
|
94 |
logger.info(f"Downloaded JSON file to: {file_path}")
|
95 |
return file_path
|
96 |
|
97 |
+
# --- Load Forbidden Names ---
|
98 |
+
def load_forbidden_names(filename="c.txt"):
|
99 |
+
"""Loads forbidden names from the specified file."""
|
100 |
+
try:
|
101 |
+
with open(filename, "r", encoding='utf-8') as f:
|
102 |
+
forbidden_names = [line.strip() for line in f]
|
103 |
+
return forbidden_names
|
104 |
+
except FileNotFoundError:
|
105 |
+
print(f"Error: Forbidden names file '{filename}' not found.")
|
106 |
+
return []
|
107 |
+
|
108 |
+
# --- Name Similarity Check ---
|
109 |
+
def check_name_similarity(name, forbidden_names, threshold=80):
|
110 |
+
"""Checks if a name is similar to any forbidden name."""
|
111 |
+
from fuzzywuzzy import fuzz
|
112 |
+
for forbidden_name in forbidden_names:
|
113 |
+
similarity_ratio = fuzz.ratio(name.lower(), forbidden_name.lower())
|
114 |
+
if similarity_ratio >= threshold:
|
115 |
+
logging.info(f"Forbidden word {forbidden_name} detected in: {name}")
|
116 |
+
return True
|
117 |
+
return False
|
118 |
+
|
119 |
# --- UI Components ---
|
120 |
|
121 |
with gr.Blocks() as app:
|
|
|
158 |
json_download_btn = gr.Button("Prepare .json for Download")
|
159 |
json_file = gr.File(label="Download Config JSON", file_count="single")
|
160 |
|
161 |
+
# --- Load Forbidden Names ---
|
162 |
+
|
163 |
+
forbidden_names = load_forbidden_names()
|
164 |
+
|
165 |
+
# --- Event Handlers ---
|
166 |
|
167 |
def calculate_journal_sum(text, date_words):
|
168 |
"""Calculates the journal sum and updates the step value."""
|
169 |
+
if check_name_similarity(text, forbidden_names):
|
170 |
+
return 0, 0, 0 # Raise an error if the name is forbidden
|
171 |
+
if check_name_similarity(date_words, forbidden_names):
|
172 |
+
return 0, 0, 0 # Raise an error if the name is forbidden
|
173 |
sum_value = calculate_gematria_sum(text, date_words)
|
174 |
+
return sum_value, sum_value, sum_value # Returning the same value three times
|
175 |
|
176 |
def update_step_half(float_step):
|
177 |
"""Updates the step value to half."""
|
|
|
183 |
new_step = math.ceil(float_step * 2)
|
184 |
return new_step, float_step * 2
|
185 |
|
186 |
+
|
187 |
def handle_json_download(config_json, step, rounds, strip_spaces, strip_in_braces, strip_diacritics_chk):
|
188 |
"""Handles the download of the JSON config file."""
|
189 |
return download_json_file(config_json, step, rounds, strip_spaces, strip_in_braces, strip_diacritics_chk)
|
|
|
204 |
gematria_btn.click(
|
205 |
calculate_journal_sum,
|
206 |
inputs=[gematria_text, date_words_output],
|
207 |
+
outputs=[gematria_result, step, float_step] # Assign the returned values to the correct outputs
|
208 |
)
|
209 |
|
210 |
half_step_btn.click(
|
c.txt
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Adolf Hitler
|
2 |
+
Joseph Stalin
|
3 |
+
Joseph Vissarionovich Stalin
|
4 |
+
Pol Pot
|
5 |
+
Saloth Sar
|
6 |
+
Idi Amin
|
7 |
+
Idi Amin Dada
|
8 |
+
Saddam Hussein
|
9 |
+
Saddam Hussein Abd al Majid al Tikriti
|
10 |
+
Slobodan Milosevic
|
11 |
+
Radovan Karadzic
|
12 |
+
Ratko Mladic
|
13 |
+
Charles Taylor
|
14 |
+
Charles McArthur Ghankay Taylor
|
15 |
+
Augusto Pinochet
|
16 |
+
Augusto Jose Ramon Pinochet Ugarte
|
17 |
+
Bashar al Assad
|
18 |
+
Bashar Hafez al Assad
|
19 |
+
Kim Jong il
|
20 |
+
Yuri Irsenovich Kim
|
21 |
+
Kim Jong un
|
22 |
+
Benito Mussolini
|
23 |
+
Benito Amilcare Andrea Mussolini
|
24 |
+
Hideki Tojo
|
25 |
+
Francisco Franco
|
26 |
+
Francisco Franco Bahamonde
|
27 |
+
Nicolae Ceausescu
|
28 |
+
Muammar Gaddafi
|
29 |
+
Efrain Rios Montt
|
30 |
+
Mengistu Haile Mariam
|
31 |
+
Laurent Desire Kabila
|
32 |
+
Ante Pavelic
|
33 |
+
Jean Bedel Bokassa
|
34 |
+
Hissene Habre
|
35 |
+
Omar al Bashir
|
36 |
+
Radislav Krstic
|
37 |
+
Milorad Trbic
|
38 |
+
Milan Lukic
|
39 |
+
Vojislav Seselj
|
40 |
+
Fulgencio Batista
|
41 |
+
Joseph Goebbels
|
42 |
+
Heinrich Himmler
|
43 |
+
Hermann Goring
|
44 |
+
Reinhard Heydrich
|
45 |
+
Adolf Eichmann
|
46 |
+
Rudolf Hess
|
47 |
+
Ernst Kaltenbrunner
|
48 |
+
Wilhelm Keitel
|
49 |
+
Alfred Rosenberg
|
50 |
+
Hans Frank
|
51 |
+
Arthur Seyss Inquart
|
52 |
+
Julius Streicher
|
53 |
+
Fritz Sauckel
|
54 |
+
Alfred Jodl
|
55 |
+
Martin Bormann
|
56 |
+
Joachim von Ribbentrop
|
57 |
+
Karl Donitz
|
58 |
+
Walther Funk
|
59 |
+
Baldur von Schirach
|
60 |
+
Hjalmar Schacht
|
61 |
+
Otto Ohlendorf
|
62 |
+
Oswald Pohl
|
63 |
+
Franz Stangl
|
64 |
+
Friedrich Jeckeln
|
65 |
+
Erich Koch
|
66 |
+
Odilo Globocnik
|
67 |
+
Albert Speer
|
68 |
+
Erwin Rommel
|
requirements.txt
CHANGED
@@ -3,3 +3,5 @@ deep_translator==1.9.0
|
|
3 |
tabulate==0.9.0
|
4 |
gradio_calendar==0.0.4
|
5 |
inflect==7.2.1
|
|
|
|
|
|
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
|