首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:注释器"sentiment“需要注释器"binarized_trees”

错误:注释器"sentiment“需要注释器"binarized_trees”
EN

Stack Overflow用户
提问于 2015-05-27 04:12:27
回答 1查看 414关注 0票数 0

当这个错误可能发生时,有人能帮助我吗?任何想法都是非常受欢迎的。我需要添加什么吗,任何注释器。这是我从默认模型传递的数据或模型的问题吗?

我使用Standford NLP 3.4.1对社交媒体数据进行情感计算。当我通过spark/scala作业运行它时,我得到了一些数据的以下错误。

代码语言:javascript
复制
java.lang.IllegalArgumentException: annotator "sentiment" requires annotator "binarized_trees"
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:300)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:129)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:125)
    at com.pipeline.sentiment.NonTwitterSentimentAndThemeProcessorAction$.create(NonTwitterTextEnrichmentComponent.scala:142)
    at com.pipeline.sentiment.NonTwitterTextEnrichmentInitialized.action$lzycompute(NonTwitterTextEnrichmentComponent.scala:52)
    at com.pipeline.sentiment.NonTwitterTextEnrichmentInitialized.action(NonTwitterTextEnrichmentComponent.scala:50)
    at com.pipeline.sentiment.NonTwitterTextEnrichmentInitialized.action(NonTwitterTextEnrichmentComponent.scala:49)

以下是我在scala中的代码

代码语言:javascript
复制
 def create(features: Seq[String] = Seq("tokenize", "ssplit", "pos","parse","sentiment")): TwitterSentimentAndThemeAction = {
      println("comes inside the TwitterSentimentAndThemeProcessorAction create method")
      val props = new Properties()
      props.put("annotators", features.mkString(", "))
      props.put(""pos.model", "tagger/gate-EN-twitter.model");
      props.put("parse.model", "tagger/englishSR.ser.gz");
      val pipeline = new StanfordCoreNLP(props)

任何帮助都是非常感谢的。谢谢你的帮助

EN

回答 1

Stack Overflow用户

发布于 2015-05-28 03:51:22

...Are你确定这就是你得到的错误吗?使用您的代码,我会得到一个错误

Loading parser from serialized file tagger/englishSR.ser.gz ...edu.stanford.nlp.io.RuntimeIOException: java.io.IOException: Unable to resolve "tagger/englishSR.ser.gz" as either class path, filename or URL

这更有意义。shift reduce解析器模型位于edu/stanford/nlp/models/srparser/englishSR.ser.gz。如果我不使用shift reduce模型,那么编写的代码对我来说工作得很好;同样,如果我在上面包含模型路径,它也可以工作得很好。

我尝试的代码是:

代码语言:javascript
复制
#!/bin/bash
exec scala -J-mx4g "$0" "$@"
!#

import scala.collection.JavaConversions._
import edu.stanford.nlp.pipeline._
import java.util._

val props = new Properties()
props.put("annotators", Seq("tokenize", "ssplit", "pos","parse","sentiment").mkString(", "))
props.put("parse.model", "edu/stanford/nlp/models/srparser/englishSR.ser.gz");
val pipeline = new StanfordCoreNLP(props)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30468010

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档