我想我需要edu.stanford.nlp包中的Semgrex。对于这个任务,我需要从edu.stanford.nlp.trees.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构建树的建议。
发布于 2017-04-04 19:37:04
您希望从您的SemanticGraph文件中加载一个CoNLL。
import edu.stanford.nlp.trees.ud.ConLLUDocumentReader;
...
CoNLLUDocumentReader reader = new CoNLLUDocumentReader();
Iterator<SemanticGraph> it = reader.getIterator(IOUtils.readerFromString(conlluFile));这将产生一个Iterator,为您的文件中的每个句子提供一个SemanticGraph。
从依赖分析中生成一个选区树是一个开放的研究问题,因此斯坦福大学CoreNLP目前无法做到这一点,据我所知。
https://stackoverflow.com/questions/43210411
复制相似问题