2

I have the same question that was posted 2 years ago here:

How to use Stanford parser

On that page, SahelSoft says they found an answer:

"I solved this problem. The problem was the conflict between stanford parser package and stanford coreNLP package in my workspace."

They don't really say what the answer is. I am new to Java and I trouble figuring out what it would mean to have a conflict between 2 packages. Can anyone offer any enlightenment?

The actual error looks like this:

Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... Exception in thread "main" edu.stanford.nlp.io.RuntimeIOException: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz" as either class path, filename or URL
at 
    edu.stanford.nlp.parser.common.ParserGrammar.loadModel(ParserGrammar.java:183)

at edu.stanford.nlp.pipeline.ParserAnnotator.loadModel(ParserAnnotator.java:197)

at edu.stanford.nlp.pipeline.ParserAnnotator.<init>(ParserAnnotator.java:107)

at edu.stanford.nlp.pipeline.AnnotatorImplementations.parse(AnnotatorImplementations.java:145)

at edu.stanford.nlp.pipeline.AnnotatorFactories$11.create(AnnotatorFactories.java:453)

at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85)

at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:289)

at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:126)

at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:122)

at com.rollioapp.nlp.Main.main(Main.java:53)

Caused by: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz" as either class path, filename or URL

at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:481)

at edu.stanford.nlp.io.IOUtils.readObjectFromURLOrClasspathOrFileSystem(IOUtils.java:313)

at edu.stanford.nlp.parser.common.ParserGrammar.loadModel(ParserGrammar.java:180)

The import statements at the top of the file look like this:

package com.ollio.nlp;

import edu.stanford.nlp.ie.AbstractSequenceClassifier;
import edu.stanford.nlp.ie.crf.CRFClassifier;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreAnnotations.*;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import edu.stanford.nlp.parser.lexparser.Options;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;

import edu.stanford.nlp.process.Tokenizer;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.trees.TreeCoreAnnotations;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.StringUtils;
import jdk.internal.org.xml.sax.InputSource;

import javax.swing.text.Document;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.lang.System.*;
Community
  • 1
  • 1
charlottesville
  • 467
  • 5
  • 19
  • 4
    Please show how you are invoking your program (e.g. command line arguments). You need to have both Stanford CoreNLP/Parser and the accompanying models jar in your classpath. – Jon Gauthier Jun 18 '15 at 03:17
  • Add `models` to include CoreNLP serialized models. Refer [this](https://stackoverflow.com/questions/27912176/stanford-parser-java-error) related thread. – CᴴᴀZ Apr 26 '18 at 13:36

0 Answers0