简体   繁体   English

Google 的 Cloud Translation API 不翻译

[英]Google's Cloud Translation API is not translating

I wrote ami valo achi in google translate.我在谷歌翻译中写了ami valo achi The proper translation of this is I'm fine .正确的翻译是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.但是当我尝试使用Cloud Translation API翻译相同的text时,它不会翻译。 It shows the exact same text I gave as input.它显示了我作为输入给出的完全相同的text 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.谷歌翻译器是谷歌开发的一款产品,它不仅实现了GCP Translation AI,还实现了其他各种组件。因此,翻译的差异不仅是常见的,而且是意料之中的。

Cloud Translation API is designed for programmatic use. Cloud Translation API 专为编程使用而设计。 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. Cloud Translation API 使用谷歌预训练的神经机器翻译 (NMT) 模型进行翻译,谷歌翻译使用统计机器翻译 (SMT),其中计算机分析数百万现有的翻译文档以学习词汇并寻找语言模式。 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.目前,Cloud translate API 不支持翻译以拉丁字母书写的孟加拉语。 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.相反,在翻译“ami valo achi”时不起作用,因为它不是用孟加拉字母书写的。

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 .但是,我们目前无法提供预计到达时间,但您可以“加注星标”问题以接收自动更新,并通过参考此链接给予关注。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM