I’m trying to use ONMT-py from within a small app. In previous versions (i’m talking commit 26421ce20c6b626ceacafbb3282cad1d5dce04ca ) i could simply do as follows:
def translate(input_statement): translator = onmt.Translator(translator_args) response, score_raw, _, _, _ = translator.translate(srcBatch=[input_statement.text.split()], goldBatch=) return response
And I would be able to get a translation from a string.
Now I’m trying to do the same with the latest version in the repo, and I’m not sure what’s the best way to not depend upon a file, since the
Tranlator.translate() method uses an object
batch, which comes from an
onmt.IO.OrderedIterator, which comes from an
onmt.IO.ONMTDataset which requires a file to load the source from.
Is there a simpler way to get to that same object so i can use the
translate() method that does not involve reading from a file? What am i missing?
Or an easy way to generate the
ONMTDataset object from just a string? Seems a bit convoluted, but as far as i understood the structure, it’s either that or creating a custom
I did look for documentation and searcherd the forum, but couldn’t find anything.