Home > OS >  script doesn't see all hebrew characters how to add hidden characters?
script doesn't see all hebrew characters how to add hidden characters?

Time:05-29

the script does not work with all Hebrew characters only with part

I need help looking for a solution here and I don't know how to do it or use it when searching here I found this I don't know how to use it storm would anyone help me with that?

as can be seen in the picture on the left is a sign, but the python does not recognize it because it seems that Hebrew also has hidden charactersenter image description here

let pSymbols={"א":126,"בּ":128,"ב":128,"ג":94,"ד":122,"ה":120,"ו":36,"ז":86,"ח":118,"ט":120,"י":36,"כּ":102,"כ":102,"ךּ":110,"ך":110,"ל":102,"מ":128,"ם":118,"נ":72,"ן":36,"ס":126,"ע":118,"פּ":116,"פ":116,"ף":116,"צ":110,"ץ":108,"ק":112,"ר":110,"שׁ":152,"שׂ":152,"תּ":142,"ת":142,"ש":152};



// Sample input -- I added one more character with punctuation
//   (Sorry for making a mess of Hebrew -- I don't know it)
let val ="םלוע םולששׂ";

// Use a regular expression that will capture punctuation 
//   together with the main character it applies to:
for (let ch of val.match(/.[\u05BC\u05C1\u05C2]?/gu)) {
    console.log(ch, pSymbols[ch]);
}

this helped someone how can i add it to my script to make it work the same?

import itertools

alphabet = {
    "א": 1,
    "ב": 2,
    "ג": 3,
    "ד": 4,
    "ה": 5,
    "ו": 6,
    "ז": 7,
    "ח": 8,
    "ט": 9,
    "י": 10,
    "כ": 20,
    "ל": 30,
    "מ": 40,
    "נ": 50,
    "ס": 60,
    "ע": 70,
    "פ": 80,
    "צ": 90,
    "ק": 100,
    "ר": 200,
    "ש": 300,
    "ת": 400

}




def gematria(word):
    result = 0
    for char in word:
        result  = alphabet[char]
    return result



if __name__ == '__main__':
    values = gen_combination_values(1)
    for i in combinations_w("כַּחֲצִי"):
        print(i)

I've been trying to do this for a few days now and the show doesn't work

   for c in word:
        if c in alphabet:
            letters_values.append(alphabet[c])

I tried this but it destroys the whole script because it only uses part of the letters

unfortunately the script does not see all the characters of Hebrew

because I still have hidden characters, but when I add them, they change themselves, so without a result

alphabet = {
    "א": 1,
    "ב": 20,
    "ג": 30,
    "ד": 400,
    "הּ": 5000,
    "וָ": 60000,
    "וָ": 60000,
    "ז": 700000,
    "ח": 8000000,
    "ט": 90000000,
    "י": 100000000,
    "ך": 1100000000,
    "כ": 1100000000,
    "ל": 1100000000,
    "מ": 100000000,
    "ם": 100000000,
    "נ": 90000000,
    "ן": 90000000,
    "ס": 8000000,
    "ע": 700000,
    "פ": 60000,
    "ף": 60000,
    "ץ": 5000,
    "צ": 5000,
    "ק": 400,
    "ר": 30,
    "ש": 20,
    "ת": 1


}

CodePudding user response:

If i understand right, the problem is that the python code crashes for the example due to "missing" symbol which is, however, inside the dictionare. If this is right, then you can solve it by iterating through symbols like this:

import regex
word_symbols = regex.findall("\\p{L}", word)
for c in word_symbols:
   ...

instead of:

for c in word:
   ...

i.e.

def combinations_w(word):
    """returns all possible word with replacement by each letter value """
    import regex

    word_symbols  = regex.findall("\\p{L}", word) # <<< here
    letters_values = []
    for c in word_symbols:
    ... the rest of the code ...

after this change, the code finds all symbols in the strings.

  • Related