I wrote ami valo achi
in google translate. The proper translation of this is I'm fine
. Google translate shows the exact same result.
But when I try to translate the same text
using Cloud Translation API
, it doesn't translate. It shows the exact same text
I gave as input. Here's my code segment:
const { Translate } = require("@google-cloud/translate").v2;
const translate = new Translate({
keyFilename: "file path",
});
let target = 'en'
let text = 'ami valo achi'
async function detectLanguage() {
let [translations] = await translate.translate(text, target);
translations = Array.isArray(translations) ? translations : [translations];
console.log("Translations:");
translations.forEach((translation, i) => {
console.log(translation)
console.log(`${text[i]} => (${target}) ${translation}`);
});
}
detectLanguage();
Is there anything that I'm doing wrong or I can do to solve this?
Google translator is a product developed by Google which not only implements GCP Translation AI but also various other components.Thus the differences in translations are not only common but expected.
Cloud Translation API is designed for programmatic use. Cloud Translation API uses Google pre-trained Neural Machine Translation (NMT) model for translation and Google Translate uses statistical machine translation (SMT), where computers analyze millions of existing translated documents to learn vocabulary and look for patterns in a language. The difference in their way of working results in different behavior. If you are not getting the same response from two different products is intended behavior.
Currently, Cloud translate API doesn’t support translation for Bengali written in the Latin alphabet. Thus, when translating "আমি ভালো আছি" into English, "i am fine" is sent back. Conversely, when translating "ami valo achi" does not work as it is not written in the Bengali alphabet.
The same has been raised as an issue in this Issue Tracker that will be updated whenever there is progress. However, we cannot provide an ETA at the moment but you can “STAR” the issue to receive automatic updates and give it traction by referring to this link.