用 R 翻译部分数据集

Translating parts of datasets with R

我打算用 R 翻译数据集中字符串变量中的简单文本。我看过 translateR 包,但是 按照帮助文件中的示例,我偶然发现需要 Google API 访问权限。

据我所知,这不是一项免费服务。 还有其他 APIS(例如 Bing),但我想 R 中没有办法到达它?

关于如何批量翻译数据框中的某些字符串数据有什么想法吗?或者我可以调查什么?

说明书里都有:?translateR::translate:

To use the Microsoft API, a client id and a client secret value must be provided. For more information on getting these, see http://msdn.microsoft.com/en-us/library/hh454950.aspx. NOTE: you do not need to obtain an access token. translateR will retrieve a token internally.

library(translateR)
res <- translate(content.vec = c("Hello world.", "This is a test."), 
                  microsoft.client.id = "foo_id", 
                  microsoft.client.secret = "fdsg54345_bar_secret_560985lkfdasd", 
                  source.lang = "en", 
                  target.lang = "de")
res
# [1] "Hallo Welt."        "Dies ist ein Test."