def check_backtranslate(self): backtranslate_output = backTranslateString(self.tables, self.input, None, mode=self.mode) template = "%-25s '%s'" report = [ "--- Backtranslate failure: %s ---" % self.__str__(), template % ("comment:", "".join(self.comment)), template % ("input:", self.input), template % ("expected text:", self.expectedOutput), template % ("actual backtranslated text:", backtranslate_output), "--- end ---", ] assert backtranslate_output == self.expectedOutput, u("\n".join(report))
def check_backtranslate(self): backtranslate_output = backTranslateString(self.tables, self.input, None, mode=self.mode) template = "%-25s '%s'" report = [ "--- Backtranslate failure: %s ---" % self.__str__(), template % ("input:", self.input), template % ("expected text:", self.expectedOutput), template % ("actual backtranslated text:", backtranslate_output), "--- end ---", ] assert backtranslate_output == self.expectedOutput, u( "\n".join(report))
def main(): print('Testing!') print('liblouis version: ' + louis.version()) print('Table Check passed!') louis.checkTable([b'./en-ueb-g2.ctb']) # something = input('type something: ') something = sys.stdin.readlines() # print("Here's what you typed: " + something) # prints the value of something and combines the ucBrl (64) and noUndefined (128) modes. Outputs as a single word, so a list is necessary to grab individual characters print("Translation in characters:") braille = louis.translateString([b'./en-ueb-g2.ctb'], something, mode=192) print(list(braille)) print("Here it is in dots:") dots = louis.charToDots([b'./en-ueb-g2.ctb'], something, mode=192) print(list(dots)) print("Here's a back-translation of what you typed:") # Returns typed phrases without contractions, for proper bash interpretation print("Back translation of characters:") backBraille = louis.backTranslateString([b'./en-ueb-g2.ctb'], braille, mode=1) print(backBraille) print("Back translation of the dots:") print(louis.dotsToChar([b'./en-ueb-g2.ctb'], dots))
def check_backtranslate(self): text = backTranslateString(self.tables, self.input, None, mode=self.mode) assert text == self.expected, self.report_error("Backtranslate", text)
def check_backtranslate(self): text = backTranslateString(self.tables, self.input, None, mode=self.mode) try: assert text == self.expected, self.report_error("Backtranslate", text) except AssertionError, e: raise SkipTest if self.xfail else e
# a partial implementation of the Braille system, and I stopped development # after integrating liblouis support. However, it's quite simple and flexible # so the functionality can be extended in future for a lightweight system that # has no external dependencies if that is desired. # if use_liblouis: import louis tableList = ["en-ueb-g2.ctb"] unicode_dots = louis.translateString(tableList, input_txt, typeform=None, mode=louis.dotsIO | louis.ucBrl) backTranslation = louis.backTranslateString(tableList, unicode_dots, typeform=None, mode=0) print( f'# input => Braille => back translation : "{input_txt}" => "{unicode_dots}" => "{backTranslation}"' ) else: from braille_fsm import BrailleTokeniser as Tokeniser from braille_fsm import BrailleTranslator as Translator btok, btrn = Tokeniser(), Translator() tokens = btok.process(input_txt) unicode_dots = btrn.process(tokens) unicode_dots = unicode_dots[0][0]
def check_backtranslate(self): text = backTranslateString(self.tables, self.input, None, mode=self.mode) assert text == self.expected, self.report_error("Backtranslate", text)