Reputation: 57
For example I want to translate something like
I found a gold locket with the inscription "From John with love"
where the actual inscription should be treated as a literal string and not translated. I tried surrounding the inscription part with double quotes when translating from English to Spanish using the conversational model but instead of this
Encontré un medallón de oro con la inscripción "From John with love"
I got this (ie the inscription part was translated as well)
Encontré un medallón de oro con la inscripción "De John con amor"
Is there some kind of escape character or other mechanism to tell the service to treat certain parts of the input as literal strings ?
Upvotes: 1
Views: 160
Reputation: 53
I'd recommend substituting the elements you don't want translated with a HTML tag that embeds the string. In your text above, you'd have...
I found a gold locket with the inscription <br class id="From John with love"/>.
This will be untouched during translation and you can map it back once you have the translation response. The main advantage is that the protected text is in the tag itself.
Upvotes: 1
Reputation: 8166
I don't believe there is any built-in support for not translating a part of a string. I think your best bet is going to be removing the parts that you don't want translated before sending the text to the Watson API, and then restore them when you get the result back.
So, for example, you could send the service the string
I found a gold locket with the inscription "12345"
And the translation is
He encontrado un locket de oro con la inscripción "12345"
You then know to go back and replace the 12345
with the original text. I just went with a number because the service doesn't seem to ever change them in translations.
Upvotes: 1