当这个错误可能发生时,有人能帮助我吗?任何想法都是非常受欢迎的。我需要添加什么吗,任何注释器。这是我从默认模型传递的数据或模型的问题吗?
我使用Standford NLP 3.4.1对社交媒体数据进行情感计算。当我通过spark/scala作业运行它时,我得到了一些数据的以下错误。
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中的代码
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)任何帮助都是非常感谢的。谢谢你的帮助
发布于 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模型,那么编写的代码对我来说工作得很好;同样,如果我在上面包含模型路径,它也可以工作得很好。
我尝试的代码是:
#!/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)https://stackoverflow.com/questions/30468010
复制相似问题