谷歌翻译 API 之间的区别

Mag*_*Tun 6 google-translate google-translation-api

我正在构建一个基于 Google 翻译的开源 Chrome 扩展(此处)。

\n\n

我已经阅读了有关 Google 翻译 API 的其他问题(例如这个这个,但我仍然没有答案。\n我发现了几个 Google 翻译的网址,如下所示:

\n\n\n\n

似乎所有 URL 都是 3 部分的不同组合:

\n\n
    \n
  • 基本网址:

    \n\n
      \n
    • translate.googleapis.com/translate_a/
    • \n
    • https://translate.google.com/translate_a/
    • \n
    • https://clients5.google.com/translate_a/
    • \n
  • \n
  • translate_a/: 或single之后的第一个参数t

  • \n
  • 客户端可以是gtx,tdict-chrome-ex[或者显然是任何 ID ]

  • \n
\n\n

到目前为止,我已经看到返回的 JSON 存在差异。\n此https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=fr&dt=t&q=father&ie=UTF-8&oe=UTF-8返回以下 json:

\n\n
[[["p\xc3\xa8re","father",null,null,1]\n]\n,null,"en"]\n
Run Code Online (Sandbox Code Playgroud)\n\n

虽然此https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=en&tl=fr&dt=t&q=father返回此 json:

\n\n
{"sentences":[{"trans":"p\xc3\xa8re","orig":"father","backend":1},{"src_translit":"\xcb\x88f\xc3\xa4T\xcd\x9fH\xc9\x99r"}],"dict":[{"pos":"noun","terms":["p\xc3\xa8re"],"entry":[{"word":"p\xc3\xa8re","reverse_translation":["father","dad","parent","papa"],"score":0.70910621,"previous_word":"le","gender":1}],"base_form":"father","pos_enum":1},{"pos":"verb","terms":["engendrer","concevoir"],"entry":[{"word":"engendrer","reverse_translation":["generate","engender","give rise to","beget","breed","father"],"synset_id":[52561],"score":0.00017133754},{"word":"concevoir","reverse_translation":["design","conceive","devise","plan","form","father"],"synset_id":[52561],"score":4.8327973e-05}],"base_form":"father","pos_enum":2}],"src":"en","alternative_translations":[{"src_phrase":"father","alternative":[{"word_postproc":"p\xc3\xa8re","score":1000,"has_preceding_space":true,"attach_to_next_token":false}],"srcunicodeoffsets":[{"begin":0,"end":6}],"raw_src_segment":"father","start_pos":0,"end_pos":0}],"confidence":1,"ld_result":{"srclangs":["en"],"srclangs_confidences":[1],"extended_srclangs":["en"]},"query_inflections":[{"written_form":"father","features":{"number":2}},{"written_form":"fathers","features":{"number":1}}],"target_inflections":[{"written_form":"p\xc3\xa8re","features":{"gender":1,"number":2}},{"written_form":"p\xc3\xa8res","features":{"gender":1,"number":1}},{"written_form":"p\xc3\xa8re","features":{"number":2}},{"written_form":"p\xc3\xa8res","features":{"number":1}}]}\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以我的问题是上面给出的不同组合之间有什么(除了这个)差异。\n在这种情况下我应该使用其中一个而不是另一个(返回的 JSON 除外)。是否有折旧或支持更多请求的产品?

\n\n

有关查询的含义:/sf/answers/2067631331/

\n

8ee*_*0d2 2

关于您的实际问题,除了您所说的之外,我不确定是否存在任何有意义的差异,并且很难确定它们中的任何一个是否以及何时被弃用。

鉴于这些 API 没有记录,并且似乎不适合以这种方式使用,我认为不应考虑将它们中的任何一个用于开发实际应用程序。


但是,为了解决您寻找免费人类语言翻译 A​​PI 的问题,我建议您使用Azure 文本翻译 API ,作为其免费套餐的一部分,它每月提供 200 万个字符的翻译。

对于您的特定用例,我认为可能存在大量重复翻译,我认为缓存结果将为减少使用量提供显着的好处。