使用openNLP的部分语音标记出错

时间:2013-09-03 19:09:51

标签: r command-line cloud opennlp pos-tagger

我有一个Ubuntu Quantal 12.10服务器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位实例”创建云实例

  • 实例中已安装的LAMP服务器

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

  • 将R版本升级至R 3.0.1

0 个答案:

没有答案