用 R 翻译部分数据集 [英] Translating parts of datasets with R

查看:38
本文介绍了用 R 翻译部分数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am intending on translating simple text in string variables in datasets with R. I have looked at the translateR package but following the example in the help file I stumbled across the need for a Google API access.

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

This is not a free service as I have become aware. There are other APIS (Bing for example) but I guess there is no way in R to get to it?

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

Any ideas on how to mass translate certain string data in a data frame? Or what I could look into?

推荐答案

都在手册中:?translateR::translate:

要使用 Microsoft API,客户端 ID 和客户端机密值必须提供.有关获取这些的更多信息,请参阅http://msdn.microsoft.com/en-us/library/hh454950.aspx.注意:你做不需要获取访问令牌.translateR 将检索一个令牌内部.

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."

这篇关于用 R 翻译部分数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆