Translate Single Sentence using OpenNMT-py

Respected fellow researchers,

I want to use my model to perform translation on single sentence and not the entire file. I have done this by using the server.py which is using flask to serve. I do not want to serve, I just want to get the translated single sentence and get output . I believe this can be done if I use TranslateClass .

I have tried this tutorial too [ Simple OpenNMT-py REST server ] , but this is not what I want , I am not trying to serve, I just want the output of the translation , when I enter the string an a input.

Has anyone done this kind of task in past.

Regards,

You can have a look at how the REST server code is built to translate single sentences. All code is in onmt.translate.translation_server.

In addition to what @francoishernandez suggested, you might want to consider CTranslate2 if you want something out of the box.

Kind regards,
Yasmin

1 Like