示例#1
0
    def get(self):

        toTranslate = self.get_argument('q')

        try:
            l1, l2 = map(toAlpha3Code, self.get_argument('langpair').split('|'))
        except ValueError:
            self.send_error(400, explanation='That pair is invalid, use e.g. eng|spa')

        mode_path = self.pairs['%s-%s' % (l1, l2)]
        try:
            _, commands = translation.parseModeFile(mode_path)
        except Exception:
            self.send_error(500)
            return

        res = yield translation.translatePipeline(toTranslate, commands)
        if self.get_status() != 200:
            self.send_error(self.get_status())
            return

        output, pipeline = res

        self.sendResponse({
            'responseData': {'output': output, 'pipeline': pipeline},
            'responseDetails': None,
            'responseStatus': 200
        })
示例#2
0
    def get(self):

        toTranslate = self.get_argument('q')

        try:
            l1, l2 = map(toAlpha3Code,
                         self.get_argument('langpair').split('|'))
        except ValueError:
            self.send_error(
                400, explanation='That pair is invalid, use e.g. eng|spa')

        mode_path = self.pairs['%s-%s' % (l1, l2)]
        try:
            _, commands = translation.parseModeFile(mode_path)
        except Exception:
            self.send_error(500)
            return

        res = yield translation.translatePipeline(toTranslate, commands)
        if self.get_status() != 200:
            self.send_error(self.get_status())
            return

        output, pipeline = res

        self.sendResponse({
            'responseData': {
                'output': output,
                'pipeline': pipeline
            },
            'responseDetails': None,
            'responseStatus': 200
        })
示例#3
0
 def getPipeCmds(self, l1, l2):
     if (l1, l2) not in self.pipeline_cmds:
         mode_path = self.pairs['%s-%s' % (l1, l2)]
         self.pipeline_cmds[(l1, l2)] = translation.parseModeFile(mode_path)
     return self.pipeline_cmds[(l1, l2)]
示例#4
0
 def getPipeCmds(self, l1, l2):
     if (l1, l2) not in self.pipeline_cmds:
         mode_path = self.pairs['%s-%s' % (l1, l2)]
         self.pipeline_cmds[(l1, l2)] = translation.parseModeFile(mode_path)
     return self.pipeline_cmds[(l1, l2)]