我想我需要 edu.stanford.nlp 包中的 Semgrex。对于这项任务,我需要从 edu.stanford.nlp.trees.Tree 构造 Tree 并像处理该树一样
import edu.stanford.nlp.semgraph.semgrex.SemgrexMatcher;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.semgraph.SemanticGraphFactory;
public class SemgrexDemo {
public static void main(String[] args) {
Tree someHowBuiltTree;//idnt know how to construct Tree from conll
SemanticGraph graph = SemanticGraphFactory.generateUncollapsedDependencies(someHowBuiltTree);
SemgrexPattern semgrex = SemgrexPattern.compile("{}=A <<nsubj {}=B");
SemgrexMatcher matcher = semgrex.matcher(graph);
}
}
实际上我需要一些关于如何从 conll 中构造树的建议。