Scala stanford corenlp feeling bug - local class incompatible

I am trying to use the Stanford corenlp java library from scala. The first error I came across was java.lang.NoClassDefFoundError: org / ejml / simple / SimpleBase. There is no mention of the org.ejml dependency mentioned on the corenlp website, or the Java code examples demonstrate import. However, I put the jjml jar in / lib dir, then import, and I can create a matrix, but when I try to access corenlp with the code below, I get:

> run
[info] Running Sentiment 
Adding annotator tokenize
TokenizerAnnotator: No tokenizer type provided. Defaulting to PTBTokenizer.
Adding annotator ssplit
Adding annotator parse
Loading parser from serialized file edu/stanford/nlp/models/lexparser    /englishPCFG.ser.gz ... done [0.3 sec].
Adding annotator sentiment
[error] (run-main-19) edu.stanford.nlp.io.RuntimeIOException:    java.io.InvalidClassException: org.ejml.simple.SimpleBase; local class incompatible: stream classdesc serialVersionUID = 7560584869544985034, local class serialVersionUID = -4908174115141247692

Is there a workaround for this?

Contents of my / lib

lib/
 EJML-core-0.28.jar
 EJML-dense64-0.28.jar
 EJML-simple-0.28.jar
 opencsv-3.6.jar
 stanford-corenlp-3.5.2-models.jar
 stanford-corenlp-3.5.2.jar

scala code

object Sentiment {

  import java.io.FileReader
  import java.util.Properties
  import com.opencsv._
  import scala.collection.JavaConversions._
  // corenlp
  import edu.stanford.nlp.ling.CoreAnnotations;
  import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations
  import edu.stanford.nlp.pipeline.Annotation;
  import edu.stanford.nlp.pipeline.StanfordCoreNLP
  import edu.stanford.nlp.sentiment.SentimentCoreAnnotations.SentimentAnnotatedTree
  import edu.stanford.nlp.trees.Tree
  import edu.stanford.nlp.util.CoreMap

  import org.ejml.simple._




def build_pipeline() = {
    val props = new Properties()
    props.setProperty("annotators", "tokenize, ssplit, parse, sentiment")
    val pipeline = new StanfordCoreNLP(props)
}

def main(args: Array[String]) = {

    val pipeline = build_pipeline
    // additional code to go here

    }
}
0
source share

Source: https://habr.com/ru/post/1664784/


All Articles