Spaces:
Sleeping
Sleeping
neuralworm
commited on
Commit
•
cd52d3a
1
Parent(s):
a9b8e9f
english translation of results
Browse files- app.py +13 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -5,6 +5,7 @@ import sqlite3
|
|
5 |
import logging
|
6 |
from util import process_json_files
|
7 |
from gematria import calculate_gematria
|
|
|
8 |
|
9 |
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
10 |
|
@@ -71,6 +72,13 @@ def search_gematria_in_db(gematria_sum):
|
|
71 |
conn.close()
|
72 |
return results
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
def db(tanach_texts, max_phrase_length=1):
|
75 |
initialize_database()
|
76 |
populate_database(tanach_texts, max_phrase_length)
|
@@ -94,9 +102,12 @@ def gematria_search_interface(phrase):
|
|
94 |
if not matching_phrases:
|
95 |
return "Keine passenden Phrasen gefunden.", "\n".join(debug_output)
|
96 |
|
|
|
|
|
|
|
97 |
result = "Passende Phrasen:\n"
|
98 |
-
for match in matching_phrases:
|
99 |
-
result += f"Buch: {match[
|
100 |
|
101 |
return result, "\n".join(debug_output)
|
102 |
|
|
|
5 |
import logging
|
6 |
from util import process_json_files
|
7 |
from gematria import calculate_gematria
|
8 |
+
from deep_translator import GoogleTranslator
|
9 |
|
10 |
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
11 |
|
|
|
72 |
conn.close()
|
73 |
return results
|
74 |
|
75 |
+
def translate_phrases(phrases):
|
76 |
+
translator = GoogleTranslator(source='auto', target='en')
|
77 |
+
translated_phrases = []
|
78 |
+
for phrase in phrases:
|
79 |
+
translated_phrases.append(translator.translate(phrase))
|
80 |
+
return translated_phrases
|
81 |
+
|
82 |
def db(tanach_texts, max_phrase_length=1):
|
83 |
initialize_database()
|
84 |
populate_database(tanach_texts, max_phrase_length)
|
|
|
102 |
if not matching_phrases:
|
103 |
return "Keine passenden Phrasen gefunden.", "\n".join(debug_output)
|
104 |
|
105 |
+
phrases = [match[0] for match in matching_phrases]
|
106 |
+
translations = translate_phrases(phrases)
|
107 |
+
|
108 |
result = "Passende Phrasen:\n"
|
109 |
+
for match, translation in zip(matching_phrases, translations):
|
110 |
+
result += f"Buch: {match[2]} ({match[3]})\nKapitel: {match[4]}, Vers: {match[5]}\nPhrase: {match[0]}\nÜbersetzung: {translation}\n\n"
|
111 |
|
112 |
return result, "\n".join(debug_output)
|
113 |
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
gradio==4.31.0
|
|
|
|
1 |
gradio==4.31.0
|
2 |
+
deep_translator==1.11.4
|