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:
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 translate().
I did look for documentation and searcherd the forum, but couldn’t find anything.
Hi, your proposed method would be only feasible (but yes, rather cumbersome) way now.
Previously, there are users asking for support of translating a single sentence, we thought
it is easy to fake it as a file to use current interface, so we don’t add that support.
But your requirement seems reasonable, maybe later when I refactor the translate part of
code, I will implement this.
Hi, I am wondering if there is any new progress on this problem. I spend some time, but no success. @juanshlm solution does not work anymore because of the updates in the project. I tried to adapt it but it does not work yet. Any help will be appreciated? I believe this can be an important future for anyone who will try to use project in a demo application rather than experiments. Thanks