|
import json |
|
from prettytable import PrettyTable |
|
from colorama import Fore, Style |
|
from collections import defaultdict |
|
import unicodedata |
|
|
|
def strip_diacritics(text): |
|
""" |
|
Entfernt Diakritika von Unicode-Zeichen, um den Basisbuchstaben zu erhalten, und gibt Warnungen |
|
f眉r tats盲chlich unbekannte Zeichen aus. |
|
""" |
|
stripped_text = '' |
|
for char in unicodedata.normalize('NFD', text): |
|
if unicodedata.category(char) not in ['Mn', 'Cf']: |
|
stripped_text += char |
|
else: |
|
print(f"Info: Diakritisches Zeichen '{char}' wird ignoriert.") |
|
return stripped_text |
|
|
|
def hebrew_letter_to_value(letter): |
|
""" |
|
Konvertiert einen einzelnen Buchstaben in seinen Gematria-Wert, ignoriert Leerzeichen |
|
und Nicht-Buchstaben-Zeichen. |
|
""" |
|
|
|
values = { |
|
|
|
'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 600, |
|
'k': 10, 'l': 20, 'm': 30, 'n': 40, 'o': 50, 'p': 60, 'q': 70, 'r': 80, 's': 90, |
|
't': 100, 'u': 200, 'v': 700, 'w': 900, 'x': 300, 'y': 400, 'z': 500, |
|
|
|
'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 600, |
|
'K': 10, 'L': 20, 'M': 30, 'N': 40, 'O': 50, 'P': 60, 'Q': 70, 'R': 80, 'S': 90, |
|
'T': 100, 'U': 200, 'V': 700, 'W': 900, 'X': 300, 'Y': 400, 'Z': 500, |
|
|
|
|
|
'丕': 1, '兀': 1, '廿': 1, '丌': 1, '亘': 2, '噩': 3, '丿': 4, '賴': 5, '賵': 6, '夭': 7, '丨': 8, '胤': 9, |
|
'賷': 10, '賶': 10, '賰': 20, '讴': 20, '賱': 30, '賲': 40, '賳': 50, '爻': 60, '毓': 70, '賮': 80, |
|
'氐': 90, '賯': 100, '乇': 200, '卮': 300, '鬲': 400, '孬': 500, '禺': 600, '匕': 700, '囟': 800, '馗': 900, '睾': 1000, |
|
'俦': 1, |
|
'賭': 0, |
|
|
|
|
|
'丞': 400, |
|
'丐': 6, |
|
'卅': 10, |
|
'亍': 1, |
|
'賶': 10, |
|
'俟': 400, |
|
'倬': 2, |
|
'趩': 3, |
|
'跇': 7, |
|
'诏': 20, |
|
'诃': 20, |
|
'诤': 50, |
|
'踿': 5, |
|
'蹝': 10, |
|
'貗': 0, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'讗': 1, '讘': 2, '讙': 3, '讚': 4, '讛': 5, '讜': 6, '讝': 7, '讞': 8, '讟': 9, '讬': 10, |
|
'讻': 20, '讱': 500, '诇': 30, '诪': 40, '诐': 600, '谞': 50, '谉': 700, '住': 60, '注': 70, '驻': 80, '祝': 800, |
|
'爪': 90, '抓': 900, '拽': 100, '专': 200, '砖': 300, '转': 400, |
|
|
|
|
|
'伪': 1, '尾': 2, '纬': 3, '未': 4, '蔚': 5, '蠞': 6, '味': 7, '畏': 8, '胃': 9, '喂': 10, |
|
'魏': 20, '位': 30, '渭': 40, '谓': 50, '尉': 60, '慰': 70, '蟺': 80, '蠠': 90, '蟻': 100, |
|
'蟽': 200, '蟿': 300, '蠀': 400, '蠁': 500, '蠂': 600, '蠄': 700, '蠅': 800, '稀': 900, |
|
|
|
|
|
'螒': 1, '螔': 2, '螕': 3, '螖': 4, '螘': 5, '蠝': 6, '螙': 7, '螚': 8, '螛': 9, '螜': 10, |
|
'螝': 20, '螞': 30, '螠': 40, '螡': 50, '螢': 60, '螣': 70, '螤': 80, '蠟': 90, '巍': 100, |
|
'危': 200, '韦': 300, '违': 400, '桅': 500, '围': 600, '唯': 700, '惟': 800, '蠣': 900, |
|
} |
|
|
|
|
|
letter_no_diacritics = strip_diacritics(letter) |
|
|
|
if letter_no_diacritics in values: |
|
return values[letter_no_diacritics.lower()] |
|
elif letter.strip() == "": |
|
return 0 |
|
else: |
|
|
|
print(f"Warnung: Unbekanntes Zeichen '{letter}' ignoriert.") |
|
return 0 |
|
|
|
|
|
def calculate_gematria(text): |
|
"""Calculate the Gematria value of a given Hebrew text, ignoring spaces and non-Hebrew characters.""" |
|
return sum(hebrew_letter_to_value(letter) for letter in text if letter.strip() != "") |
|
|
|
|
|
|
|
def gematria(letra): |
|
valores = {'讗': 1, '讘': 2, '讙': 3, '讚': 4, '讛': 5, '讜': 6, '讝': 7, '讞': 8, '讟': 9, |
|
'讬': 10, '讻': 20, '诇': 30, '诪': 40, '谞': 50, '住': 60, '注': 70, '驻': 80, |
|
'爪': 90, '拽': 100, '专': 200, '砖': 300, '转': 400, '讱': 20, '诐': 40, '谉': 50, '祝': 80, '抓': 90} |
|
return valores.get(letra, 0) |
|
|
|
|
|
def generar_combinaciones(): |
|
letras = ['讗', '讘', '讙', '讚', '讛', '讜', '讝', '讞', '讟', '讬', '讻', '诇', '诪', '谞', '住', '注', '驻', '爪', '拽', '专', '砖', '转', |
|
'讱', '诐', '谉', '祝', '抓'] |
|
combinaciones = [] |
|
for letra1 in letras: |
|
for letra2 in letras: |
|
combinaciones.append(letra1 + letra2) |
|
return combinaciones |
|
|
|
|
|
def calcular_valores(combinacion): |
|
valor1 = gematria(combinacion[0]) |
|
valor2 = gematria(combinacion[1]) |
|
suma = valor1 + valor2 |
|
producto = valor1 * valor2 |
|
ratio = valor1 / valor2 if valor2 != 0 else float('inf') |
|
return suma, producto, ratio |
|
|
|
|
|
def main(): |
|
combinaciones = generar_combinaciones() |
|
table = PrettyTable() |
|
table.field_names = ["#", Fore.BLUE + "Producto" + Style.RESET_ALL, |
|
Fore.BLUE + "Suma" + Style.RESET_ALL, |
|
Fore.BLUE + "Ratio" + Style.RESET_ALL, |
|
Fore.BLUE + "Valor 2" + Style.RESET_ALL, |
|
Fore.BLUE + "Valor 1" + Style.RESET_ALL, |
|
Fore.BLUE + "Combinaci贸n" + Style.RESET_ALL] |
|
|
|
|
|
combinaciones_por_ratio = defaultdict(set) |
|
|
|
|
|
versos_genesis_sefardi = [ |
|
"讘专讗砖讬转 讘专讗 讗诇讛讬诐 讗转 讛砖诪讬诐 讜讗转 讛讗专抓", |
|
"讜讛讗专抓 讛讬转讛 转讛讜 讜讘讛讜 讜讞砖讱 注诇志驻谞讬 转讛讜诐 讜专讜讞 讗诇讛讬诐 诪专讞驻转 注诇志驻谞讬 讛诪讬诐", |
|
"讜讬讗诪专 讗诇讛讬诐 讬讛讬 讗讜专 讜讬讛讬志讗讜专", |
|
"讜讬专讗 讗诇讛讬诐 讗转志讛讗讜专 讻讬志讟讜讘 讜讬讘讚诇 讗诇讛讬诐 讘讬谉 讛讗讜专 讜讘讬谉 讛讞砖讱", |
|
"讜讬拽专讗 讗诇讛讬诐 诇讗讜专 讬讜诐 讜诇讞砖讱 拽专讗 诇讬诇讛 讜讬讛讬志注专讘 讜讬讛讬志讘拽专 讬讜诐 讗讞讚" |
|
|
|
] |
|
|
|
|
|
def obtener_primer_par_letras(verso): |
|
for i in range(len(verso) - 1): |
|
if verso[i].isalpha() and verso[i+1].isalpha(): |
|
return verso[i:i+2] |
|
return None |
|
|
|
|
|
primer_par_por_verso = {} |
|
for verso in versos_genesis_sefardi: |
|
primer_par = obtener_primer_par_letras(verso) |
|
if primer_par: |
|
suma, producto, ratio = calcular_valores(primer_par) |
|
primer_par_por_verso[verso] = (primer_par, ratio) |
|
|
|
|
|
primer_par_por_ratio = defaultdict(list) |
|
for verso, (primer_par, ratio) in primer_par_por_verso.items(): |
|
primer_par_por_ratio[ratio].append((primer_par, verso)) |
|
|
|
|
|
table_primer_par = PrettyTable() |
|
table_primer_par.field_names = [Fore.BLUE + "Primer Par" + Style.RESET_ALL, Fore.BLUE + "Ratio" + Style.RESET_ALL, Fore.BLUE + "Verso" + Style.RESET_ALL] |
|
for ratio, pares_verso in sorted(primer_par_por_ratio.items(), key=lambda x: x[0], reverse=True): |
|
for primer_par, verso in pares_verso: |
|
table_primer_par.add_row([primer_par, f"{ratio:.2f}", verso]) |
|
|
|
print(table_primer_par) |
|
|
|
|
|
for idx, combinacion in enumerate(combinaciones, start=1): |
|
suma, producto, ratio = calcular_valores(combinacion) |
|
combinacion_str = combinacion |
|
|
|
if combinacion in set(''.join(obtener_primer_par_letras(verso)) for verso in versos_genesis_sefardi): |
|
combinacion_str = Fore.GREEN + combinacion + Style.RESET_ALL |
|
table.add_row([idx, producto, suma, f"{ratio:.2f}", gematria(combinacion[1]), gematria(combinacion[0]), combinacion_str]) |
|
combinaciones_por_ratio[ratio].add(combinacion) |
|
|
|
|
|
print("\nTabla de combinaciones:") |
|
print(table) |
|
|
|
|
|
print("\nTabla de combinaciones agrupadas por ratio:") |
|
table_ratio = PrettyTable() |
|
table_ratio.field_names = [Fore.BLUE + "Ratio" + Style.RESET_ALL, Fore.BLUE + "Combinaciones" + Style.RESET_ALL] |
|
for ratio, combinaciones in sorted(combinaciones_por_ratio.items(), key=lambda x: x[0], reverse=True): |
|
combinaciones_str = ", ".join(combinaciones) |
|
table_ratio.add_row([f"{ratio:.2f}", combinaciones_str]) |
|
print(table_ratio) |
|
|
|
|
|
primeros_pares_unicos = set(primer_par for primer_par, _ in primer_par_por_verso.values()) |
|
num_primeros_pares_unicos = len(primeros_pares_unicos) |
|
num_combinaciones_totales = len(combinaciones) |
|
print(f"\nN煤mero de primeros pares de letras 煤nicos: {num_primeros_pares_unicos}") |
|
print(f"N煤mero de combinaciones totales posibles: {num_combinaciones_totales}") |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|