@cherrypy.expose
    def translate(self, **kwargs):
        response = cherrypy.response
        response.headers['Content-Type'] = 'application/json'

        q = self.filter.filter(kwargs["q"])
        raw_src = q
        self.log("The server is working on: %s" %repr(raw_src))
        self.log_info("Request before preprocessing: %s" %repr(raw_src))
        translationDict = {"sourceText":raw_src.strip()}
       
	lower_src = raw_src.lower() 
	tokenized_src = self.tokenize(lower_src)
        
	translation = ''

        # query MT engine
	self.log_info("Requesting translation for %s" % repr(tokenized_src))
        result = self._translate(tokenized_src)
        if 'text' in result:
            translation = result['text']
        else:
            return self._timeout_error(tokenized_src, 'translation')
	self.log_info("Received translation: %s" % repr(translation))

	#
	recased_result = self._recaser(translation)
	if 'text' in recased_result:
		recased_trans=recased_result['text']
	else:
		recased_trans=translation	
	detokenized_trans = self.detokenize(recased_trans)
	detruecased_trans = self.detruecase(detokenized_trans)
	translatedText = self.filter.filter(detruecased_trans)

	translationDict = {"translatedText":translatedText}

        data = {"data" : {"translations" : [translationDict]}}
        self.log("The server is returning: %s" %self._dump_json(data))
        
	return self._dump_json(data)
dataset/ETHPy150Open PorthTechnolegauIaith/moses-smt/docker/python-server.py/Root.translate/original