# Copyright (C) 2024 igoz # See end of file for extended copyright and license notice. import unicodedata import sys mispar_hechrachi = { 'א': 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, '־': 0, } mispar_gadol = { 'א': 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, '־': 0, } isopsephy = { 'Α': 1, 'α': 1, 'Β': 2, 'β': 2, 'Γ': 3, 'γ': 3, 'Δ': 4, 'δ': 4, 'Ε': 5, 'ε': 5, 'Ϝ': 6, 'ϝ': 6, 'Ϛ': 6, 'ϛ': 6,'ς' 'Ζ': 7, 'ζ': 7, 'Η': 8, 'η': 8, 'Θ': 9, 'θ': 9, 'Ι': 10, 'ι': 10, 'Κ': 20, 'κ': 20, 'Λ': 30, 'λ': 30, 'Μ': 40, 'μ': 40, 'Ν': 50, 'ν': 50, 'Ξ': 60, 'ξ': 60, 'Ο': 70, 'ο': 70, 'Π': 80, 'π': 80, 'Ϙ': 90, 'ϙ': 90, 'Ρ': 100, 'ρ': 100, 'Σ': 200, 'σ': 200, 'ς': 200, 'Τ': 300, 'τ': 300, 'Υ': 400, 'υ': 400, 'Φ': 500, 'φ': 500, 'Χ': 600, 'χ': 600, 'Ψ': 700, 'ψ': 700, 'Ω': 800, 'ω': 800, 'Ϡ': 900, 'ϡ': 900, } def gematria(line, map): return sum(map[c] for c in line) def remove_diatrics(text): return ''.join(c for c in unicodedata.normalize('NFKD', text) if not unicodedata.combining(c)) def is_greek(line): return line and '\u0370' <= line[0] <= '\u03FF' def is_hebrew(line): return line and '\u0590' <= line[0] <= '\u05FF' def process_file(filepath): with open(filepath, 'r', encoding='utf-8') as file: row = 1 counts = {} for raw_line in file: line = remove_diatrics(raw_line.strip()) print('{:<8}\033[1m{}\033[0m'.format(f'[{row}]', line)) if is_hebrew(line): print(f' {line:<10} {'[mh]':<5} {gematria(line, mispar_hechrachi)}') print(f' {line:<10} {'[mg]':<5} {gematria(line, mispar_gadol)}') vh = gematria(line, mispar_hechrachi) vg = gematria(line, mispar_gadol) counts[vh] = counts.get(vh, 0) + 1 if vh != vg: counts[vg] = counts.get(vg, 0) + 1 elif is_greek(line): print(f' {line:<10} {'[i]':<5} {gematria(line, isopsephy)}') vi = gematria(line, isopsephy) counts[vi] = counts.get(vi, 0) + 1 else: print('\033[31m unknown\033[0m') row += 1 print('\nrepeat occurrences:') for value, count in counts.items(): if count > 1: print(f' {value}: {count}') if __name__ == '__main__': if (len(sys.argv)) == 2: process_file(sys.argv[1]) else: print(f'Usage: python {sys.argv[0]} ') sys.exit(1) # Copyright (C) 2024 igoz # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # this program. If not, see .