MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / __call__

Method __call__

openrec/preprocess/char_label_encode.py:18–32  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

16 use_space_char)
17
18 def __call__(self, data):
19 text = data['label']
20 text = self.encode(text)
21 if text is None:
22 return None
23 if len(text) > self.max_text_len:
24 return None
25 data['length'] = np.array(len(text))
26 text_char = text + [104] * (self.max_text_len + 1 - len(text))
27 text.insert(0, 2)
28 text.append(3)
29 text = text + [0] * (self.max_text_len + 2 - len(text))
30 data['label'] = np.array(text)
31 data['label_char'] = np.array(text_char)
32 return data
33
34 def add_special_char(self, dict_character):
35 dict_character = ['blank', '<unk>', '<s>', '</s>'] + dict_character

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected