Helsinki-NLP / Opus-MT

Open neural machine translation models and web services
MIT License
574 stars 71 forks source link

Error when input text contains an empty line #96

Open dlippold opened 8 months ago

dlippold commented 8 months ago

I have installed OPUS-MT on Ubuntu 22.04 as described on the project page (manual setup). I can translate some text by using the web site localhost:8888, for example from English to German. But when the input text contains an empty line I get the following error output an no text is translated:

Uncaught exception POST /api/translate (127.0.0.1) HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/translate', version='HTTP/1.1', remote_ip='127.0.0.1') Traceback (most recent call last): File "/home/opusmt/.local/lib/python3.10/site-packages/tornado/web.py", line 1784, in _execute result = method(*self.path_args, **self.path_kwargs) File "/home/opusmt/Opus-MT/server.py", line 124, in post translation = self.worker.translate(self.args['source']) File "/home/opusmt/Opus-MT/server.py", line 30, in translate sentences = self.contentprocessor.preprocess(text) File "/home/opusmt/Opus-MT/content_processor.py", line 47, in preprocess normalized_text = '\n'.join(self.normalizer(line) for line in srctxt.split('\n')) # normalizer do not accept '\n' TypeError: sequence item 2: expected str instance, list found 500 POST /api/translate (127.0.0.1) 20.03ms

Is there a possibility to translate text with empty lines?