(self, character)
| 6 | """ Convert between text-label and text-index """ |
| 7 | |
| 8 | def __init__(self, character): |
| 9 | # character (str): set of the possible characters. |
| 10 | dict_character = list(character) |
| 11 | |
| 12 | self.dict = {} |
| 13 | for i, char in enumerate(dict_character): |
| 14 | # NOTE: 0 is reserved for 'CTCblank' token required by CTCLoss |
| 15 | self.dict[char] = i + 1 |
| 16 | |
| 17 | self.character = ['[CTCblank]'] + dict_character # dummy '[CTCblank]' token for CTCLoss (index 0) |
| 18 | |
| 19 | def encode(self, text, batch_max_length=25): |
| 20 | """convert text-label into text-index. |
nothing calls this directly
no outgoing calls
no test coverage detected