5

我有一个 Ubuntu Quantal 12.10 Server 64 位实例。我正在使用 openNLP 对句子进行 POS 标记。

我正在使用带有“Parallel Lapply setup”的openNLP进行POS标记。它在 RStudio 环境中运行良好。但在 Ubuntu 环境中,它显示以下错误。

Error in do.call(c, clusterApply(cl, x = splitList(X, length(cl)), fun = lapply,   :
  second argument must be a list

对我面临的问题有什么建议吗?

这是我正在使用的代码:

tagPOS <-  function(x, ...) {

    s <- as.String(x)

    word_token_annotator <- Maxent_Word_Token_Annotator()

    a2 <- Annotation(1L, "sentence", 1L, nchar(s))

    a2 <- annotate(s, word_token_annotator, a2)

    a3 <- annotate(s, PTA, a2)

    a3w <- a3[a3$type == "word"]

    POStags <- unlist(lapply(a3w$features, `[[`, "POS"))

    POStagged <- paste(sprintf("%s/%s", s[a3w], POStags), collapse = " ")

    list(POStagged = POStagged, POStags = POStags)

  }



  cl <- makeCluster(mc <- getOption("cl.cores", detectCores()/2))

  clusterEvalQ(cl, {

    library(openNLP)

    library(NLP)

    PTA <- Maxent_POS_Tag_Annotator()

  })

这是我正在使用的设置:

  • 使用“Ubuntu Quantal 12.10 Server 64-bit instance”创建了一个云实例

  • 在实例中安装 LAMP 服务器

  • 之后我安装了 R。默认情况下,R 版本是 2.15.0

  • 将 R 版本升级到 R 3.0.1

4

0 回答 0