访问R中的Microsoft Translation API
我有很多不同语言的推文,我想将其翻译成Englisch。这些推文是在数据框架中组织的,其中一列是实际文本。
每行都有17列,其中包含不同的信息,例如User_ID,status_id,语言和文本。 看起来这样:
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
由于我的大学,我有一个Azure帐户,所以我有Microsoft API密钥。我已经在Github上看到了有关如何使用Microsoft Translation API的帖子。但是,我在访问API时遇到了问题。关于如何在Phyton或C上进行操作有很多解释,但是没有
R。 API是这样:
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')
但是每当我尝试运行代码时,这是我的错误代码:
In mclapply(to.translate, function(x) microsoftTranslate(x, microsoft.api.key, : all scheduled cores encountered errors in user code
所以我想知道,如果此问题是由于无法正确访问API吗?如果是这样,我该如何解决?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论