简体   繁体   English

在Azure ML Studio上为Microsoft R Open 3.4.4安装textshape程序包

[英]Installing textshape package for Microsoft R Open 3.4.4 on Azure ML Studio

I'm trying to use the R sentimentr package on Azure ML Studio. 我正在尝试在Azure ML Studio上使用R sentimentr包。 As this package is not supported, I'm trying to install it and its dependencies as described in the documentation . 由于不支持该软件包,因此我尝试按照文档中的说明安装它及其依赖项。

The steps that I have performed are: 我执行的步骤是:

  • downloaded Windows binaries from the R Open 3.4.4 snapshot at CRAN time machine CRAN时间机器上从R Open 3.4.4快照下载Windows二进制文件

    • sentimentr_2.2.3.zip
    • syuzhet_1.0.4.zip
    • textclean_0.6.3.zip
    • lexicon_0.7.4.zip
    • textshape_1.5.0.zip
  • zipped those zip files into a zipped folder packages.zip 将这些zip文件压缩到一个压缩文件夹packages.zip

  • uploaded packages.zip as a dataset to Microsoft Azure ML Studio packages.zip作为数据集上传到Microsoft Azure ML Studio

In my ML experiment I connect the packages.zip dataset to the "Script Bundle (Zip)" input port on "Execute R Script" and include this code: 在我的ML实验中,我将packages.zip数据集连接到“ Execute R Script”上的“ Script Bundle(Zip)”输入端口,并包含以下代码:

# install R package contained in src  
install.packages("src/lexicon_0.7.4.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/textclean_0.6.3.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/textshape_1.5.0.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/syuzhet_1.0.4.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/sentimentr_2.2.3.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

# load libraries
library(sentimentr, lib.loc = ".", verbose = TRUE)

The experiment runs successfully, until I include a function from sentimentr : 实验成功运行,直到我包含了sentimentr的函数:

mydata <- mydata %>%
  get_sentences() %>%
  sentiment()

This gives the error: 这给出了错误:

there is no package called 'textshape' 没有名为“ textshape”的软件包

Which is difficult to understand given that the output log does not indicate an issue with the packages: 鉴于输出日志并不表明软件包存在问题,这很难理解:

[Information]         The following files have been unzipped for sourcing in path=["src"]:
[Information]                           Name  Length                Date
[Information]         1 sentimentr_2.2.3.zip 3366245 2019-08-07 14:57:00
[Information]         2    syuzhet_1.0.4.zip 2918474 2019-08-07 15:05:00
[Information]         3  textclean_0.6.3.zip 1154814 2019-08-07 15:13:00
[Information]         4    lexicon_0.7.4.zip 4551995 2019-08-07 15:17:00
[Information]         5  textshape_1.5.0.zip  463095 2019-08-07 15:42:00
[Information]         Loading objects:
[Information]           port1
[Information]         [1] "Loading variable port1..."
[Information]         package 'lexicon' successfully unpacked and MD5 sums checked   
[Information]         package 'textclean' successfully unpacked and MD5 sums checked
[Information]         package 'textshape' successfully unpacked and MD5 sums checked
[Information]         package 'syuzhet' successfully unpacked and MD5 sums checked
[Information]         package 'sentimentr' successfully unpacked and MD5 sums checked

Has anyone seen this, or similar issues? 有没有人看过这个或类似的问题? Is it possible that "successfully unpacked" is not the same as successfully installed and usable? “成功打开包装”是否可能与成功安装和使用的包装不同?

I can now answer my own question thanks to a hint on Twitter from @bryan_hepworth. 由于@bryan_hepworth 在Twitter上的提示,我现在可以回答我自己的问题。

The R packages were installed correctly, but not in the standard library location. R软件包已正确安装,但不在标准库位置。 So when a function from sentimentr runs, R tries to load the dependency package textshape : 因此,当运行来自sentimentr的函数时,R尝试加载依赖项包textshape

library(textshape)

Which of course does not exist in the standard location as Azure ML does not support it. 当然,哪个位置在标准位置不存在因为Azure ML不支持它。

The solution is to load textshape explicitly from its installed location: 解决方案是从其安装位置显式加载textshape

library(textshape, lib.loc = ".")

So the solution is: explicitly load packages that you installed at the start of your R code, rather than letting R try to load them as dependencies, which will fail. 因此,解决方案是:显式加载在R代码开头安装的软件包,而不是让R尝试将它们作为依赖项加载,这将失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM