Translating parts of datasets with R
Asked Answered
B

1

1

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?

Boatright answered 13/4, 2016 at 12:22 Comment(1)
Figure out how to get the API to work first, then worry about doing it from R. Presumably you would be accessing a web service, and this could be done using any language (and possibly a web browser if the service is exposed via a GET).Flannery
R
2

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."
Roentgenotherapy answered 13/4, 2016 at 14:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.