File size: 491 Bytes
4b917c4 | 1 2 3 4 5 6 7 8 9 10 11 12 | """Preserve the trained RTL bank's explicit visual-order convention in table splits."""
class RTLVisualChar(str):
base_rtl = True
class CTCDecodeMixin:
def _decode(self, tokens):
if any(getattr(t[0], 'base_rtl', False) for t in tokens):
from indra_ocr.rtl import flip
visual = ''.join(t[0] if isinstance(t[0], str) else self.vocab.chars[t[0] - 1] for t in tokens)
return flip(visual, base_rtl=True)
return super()._decode(tokens)
|