gpt4 book ai didi

java - 斯坦福 NLP 语法关系类型?

转载 作者:行者123 更新时间:2023-11-30 12:08:20 25 4
gpt4 key购买 nike

Soo... 该程序完全按照应有的方式运行,但我不明白该程序输出的花哨缩写是什么。

如果我输入'I wish today was a school day',程序会输出

I/PRP : wish/VBP : nsubj
wish/VBP : day/NN : csubj
today/NN : wish/VBP : nmod:tmod
was/VBD : day/NN : cop
a/DT : day/NN : det
school/NN : day/NN : compound
day/NN : ROOT : root

我只想知道“cop”、“det”、“nsubj”、“csubj”等是什么;这样我就可以理解这些词之间的关系了。

String modelPath = null;
String taggerPath = null;
MaxentTagger tagger = null;
DependencyParser parser = null;
Properties props;
StanfordCoreNLP pipeline;

public ConversationEngine() {
modelPath = DependencyParser.DEFAULT_MODEL;
taggerPath = "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger";
tagger = new MaxentTagger(taggerPath);
parser = DependencyParser.loadFromModelFile(modelPath);
props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
pipeline = new StanfordCoreNLP(props);
}

public void parseSentence(String text) {
String subject = "";
DocumentPreprocessor tokenizer = new DocumentPreprocessor(new StringReader(text));
for (List<HasWord> sentence : tokenizer) {
List<TaggedWord> tagged = tagger.tagSentence(sentence);
GrammaticalStructure gs = parser.predict(tagged);
for (TypedDependency dep : gs.typedDependenciesEnhancedPlusPlus()) {
System.out.println(dep.dep() + " : " + dep.gov() + " : " + dep.reln());

}
}
}

最佳答案

我相信你想要 dep.reln().toPrettyString()(参见 GrammaticalRelation#toPrettyString)

当您在 println 中调用 dep.reln() 时,这隐含为 dep.reln().toString() 并且javadocs 声明这

Returns short name (abbreviation) for this GrammaticalRelation.

(参见 GrammaticalRelation#toString)

关于java - 斯坦福 NLP 语法关系类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54394251/

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