单词的不同含义 google 翻译 api

different meaning of words google translate api

我有问题。我使用 google 翻译 api 和一些词,例如"table" 有不同的含义。如果我将这个世界翻译成俄语(使用 api),我得到的翻译只有一种意思。我怎样才能得到几个翻译几个意思?

我的代码:

const Translate = require('@google-cloud/translate');
const translate = new Translate({
    keyFilename: 'token.json',
});
const text = 'table';
const target = 'ru';
translate
  .translate(text, target)
  .then(results => {
    console.log(`Text: ${text}`);
    console.log(`Translation: ${JSON.stringify(results)}`);
  })
  .catch(err => {
    console.error('ERROR:', err);
  });

我的输出:

Text: table
Translation: ["Таблица",{"data":{"translations":[{"translatedText":"Таблица","detectedSourceLanguage":"en"}]}}]

除了单词“Таблица”,应该是单词“Стол”

对不起我的英语。

Cloud Translation API's FAQ 中所述:

Is it possible to get multiple translations of a word?

  • No. This feature is only available via the web interface at translate.google.com

所以此功能只能通过 translate.google.com 的 Web 界面使用,因此无法使用 Cloud Translation API.

对同一内容进行多种翻译