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

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

问题描述

我打算在我看过的翻译器包河数据集翻译的字符串变量简单的文本,但
下面的帮助文件的例子我碰到需要一个谷歌API访问跌跌撞撞。

这是不是一个免费的服务,因为我已经意识到。
还有其他的API(兵为例),但我想有R中没有办法得到它?

如何在海量数据帧中的特定字符串的数据转换的任何想法?或者有什么我可以看看?


解决方案

这一切都在手册中:翻译器翻译::


  

要使用微软的API,客户端ID和客户端密钥值必须
  来提供。有关获取这些详细信息,请参阅
   http://msdn.microsoft.com/en-us/library/hh454950.aspx 。注意:您做
  不需要获得访问令牌。翻译器将检索令牌
  在内部。


 库(翻译器)
RES< - 翻译(content.vec = C(世界,你好,这是一个测试),
                  microsoft.client.id =foo_id
                  microsoft.client.secret =fdsg54345_bar_secret_560985lkfdasd
                  source.lang =EN,
                  target.lang =德)
水库
#[1]喂世界报。 模具IST EIN测试。

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.

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?

解决方案

It's all in the manual: ?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."

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

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