diff --git a/gematriapy/gematria.py b/gematriapy/gematria.py index d484b6f..ab4e6d4 100644 --- a/gematriapy/gematria.py +++ b/gematriapy/gematria.py @@ -27,6 +27,16 @@ ]) +HEBREW_ALL_LETTERS = { + **HEBREW_BASIC_LETTERS, + "ך": 20, + "ם": 40, + "ן": 50, + "ף": 80, + "ץ": 90, +} + + def to_hebrew(number: int) -> str: """ Convert number to Hebrew letter(s). @@ -68,5 +78,5 @@ def to_number(hebrew: str) -> int: """ sum = 0 for letter in hebrew: - sum += HEBREW_BASIC_LETTERS.get(letter, 0) + sum += HEBREW_ALL_LETTERS.get(letter, 0) return sum diff --git a/tests/test_to_number.py b/tests/test_to_number.py index e889423..26de01a 100644 --- a/tests/test_to_number.py +++ b/tests/test_to_number.py @@ -15,6 +15,20 @@ def test_long_hebrew_v1(self): def test_long_hebrew_v2(self): self.assertEqual(gematriapy.to_number("רטו"), 215) + def test_long_hebrew_v3(self): + self.assertEqual(gematriapy.to_number("שלום"), 376) + + def test_single_final_letter(self): + """ + In Hebrew, 'final' letters are different from regular letters. + Some letters have a special shape if positioned at the end of a word. + """ + self.assertEqual(gematriapy.to_number("ך"), 20) + self.assertEqual(gematriapy.to_number("ם"), 40) + self.assertEqual(gematriapy.to_number("ן"), 50) + self.assertEqual(gematriapy.to_number("ף"), 80) + self.assertEqual(gematriapy.to_number("ץ"), 90) + def test_illegal_hebrew_number_v1(self): """ In Hebrew, letters representing a numerical value should have an order: