无法将“edu / stanford / nlp / models / lexparser / englishPCFG.ser.gz”解析为类路径,文件名或URL

时间:2015-06-17 20:03:35

标签: java nlp stanford-nlp

我有2年前发布的相同问题:

How to use Stanford parser

在该页面上,SahelSoft说他们找到了答案:

“我解决了这个问题。问题是我工作区中stanford解析器包和stanford coreNLP包之间的冲突。”

他们并没有真正说出答案是什么。我是Java新手,我很难搞清楚两个软件包之间是否存在冲突意味着什么。任何人都可以提供任何启示吗?

实际错误如下:

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)

引起:java.io.IOException:无法将“edu / stanford / nlp / models / lexparser / englishPCFG.ser.gz”解析为类路径,文件名或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)

文件顶部的import语句如下所示:

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.*;

0 个答案:

没有答案