gpt4 book ai didi

java - 斯坦福大学崩溃依赖解析器错误: loadmodel

转载 作者:太空宇宙 更新时间:2023-11-04 13:21:19 25 4
gpt4 key购买 nike

我想要获得斯坦福大学的折叠依赖解析器。这是我的代码:

import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.Sentence;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import edu.stanford.nlp.trees.*;
import java.util.List;

class Parser{
public static void main(String[] args) {
LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
lp.setOptionFlags(new String[] { "-maxLength", "80","-retainTmpSubcategories" });
String[] sent = { "This", "is", "an", "easy", "sentence", "." };
List<CoreLabel> rawWords = Sentence.toCoreLabelList(sent);
Tree parse = lp.apply(rawWords);
parse.pennPrint();
System.out.println();

TreebankLanguagePack tlp = new PennTreebankLanguagePack();
GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
List<TypedDependency> tdl = gs.typedDependenciesCCprocessed();
System.out.println(tdl);
TreePrint tp = new TreePrint("penn,typedDependenciesCollapsed");
tp.printTree(parse);
}

}

在 Netbeans 中运行以下 2 个代码时,我收到以下错误。

对于,

LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");

我收到的错误消息是:

 cannot find symbol, symbol: method loadModel(java.lang.String), location: class.LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"); "

对于

lp.setOptionFlags(new String[] { "-maxLength", "80","-retainTmpSubcategories" });

显示以下错误消息。

setOptionFlags(java.lang.String..)is not public in edu.stanford.nlp.parser.lexparser.LexicalizedParser; cannot be accessed from outside package.

我已经导入了“stanford-corenlp-1.3.0.jar”。请问我该如何解决这个问题?

最佳答案

您是否尝试过使用斯坦福 CoreNLP 3.5.2 进行此操作?

可以在这里找到最新的下载:

http://nlp.stanford.edu/software/corenlp.shtml

关于java - 斯坦福大学崩溃依赖解析器错误: loadmodel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33031455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com