我正在使用nlp parser stanord。我想从Collection tdl中提取一些像nsubj这样的元素。我的代码是:
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
Collection tdl = gs.typedDependenciesCollapsed();但我的问题是,我不知道如何比较我从集合中获得的elements.that。
非常感谢您的帮助!
发布于 2011-04-04 03:51:06
它是TypedDependency的集合,然后可以用所有常见的Java方式进行检查或操作。例如,此代码仅打印nsubj关系:
Collection<TypedDependency> tdl = gs.typedDependenciesCCprocessed(true);
for (TypedDependency td : tdl) {
if (td.reln().equals(EnglishGrammaticalRelations.NOMINAL_SUBJECT)) {
System.out.println("Nominal Subj relation: " + td);
}
}https://stackoverflow.com/questions/5500489
复制相似问题