da03 / Attention-OCR

Visual Attention based OCR
MIT License
1.11k stars 362 forks source link

I don't understand the meaning of the code: ord(c) - 97 + 13 if ord(c) > 96 else ord(c) - 48 + 3) #102

Open vinsofts-trientt opened 5 years ago

vinsofts-trientt commented 5 years ago

I don't understand the meaning of the code Attention-OCR/src/data_util/data_gen.py line 123 : ord(c) - 97 + 13 if ord(c) > 96 else ord(c) - 48 + 3), I just know that ord (c) gives the corresponding character for given ASCII code but why "- 97 + 13" ?? Please help me

vadimen commented 3 years ago

Seems like the model understands only numbers and letters, 3 symbols are used for EOL and GO and smth else (positions 0-2), then there are 10 numbers (positions 3-12) and then there are 26 letter (positions 13-38). That's why the letter 'a' (pos 97) minus 97 + 13 goes to the 13 in the internal alphabet.