grethcool
grethcool

Reputation: 1

Accessing Microsoft Translation API in R

I have a large set of Tweets in different languages which I would like to translate to Englisch. The Tweets are organized in a dataframe, where one column is the actual text.

Each row has 17 columns with different information, such as user_id, status_id, language and text. Looking like this:

A tibble: 642,581 × 17
   user_id  status_id  created_at screen_name text    source  favorite_count retweet_count quote_count reply_count hashtags
   <chr>    <chr>      <chr>      <chr>       <chr>   <chr>   <chr>          <chr>         <chr>       <chr>       <chr>   
 1 1235580… 138959693… 2021-05-0… China_Lyon  "la bo… "Twitt… 0              15            NA          NA          "c(\"Ch…
 2 NA       135549494… 2021-01-30 Ambassador… "rt : … "<a hr… 0              0             0           0            NA     

I have an Azure Account due to my university, so I have the Microsoft API key. I saw already a post here on Github on how to use the Microsoft Translation API. However, I have problems accessing the API. There are a lot of explanations on how to do it on Phyton or C, but none for R. I was wondering, if anyone could help me accessing the Microsoft API in R.

The code example for translating the actual text column, using the Microsoft API is this one:

data(Tweets_df) 
translation_example <- translateR::translate(dataset = Tweets_df,
content.field = 'text', 
microsoft.api.key = 'my.api.key', 
source.lang = 'de', 
target.lang = 'en') 

But whenever I try to run the code, this is my error code:

In mclapply(to.translate, function(x) microsoftTranslate(x, microsoft.api.key,  :   all scheduled cores encountered errors in user code

So I was wondering, if this problem is due to not accessing the API correctly? And if so, how can I solve this?

Upvotes: -1

Views: 227

Answers (0)

Related Questions