Nlp 如何处理我从syntaxnet获得的树?(conll格式)
我想我需要来自edu.stanford.nlp包的Semgrex。对于这个任务,我需要从edu.stanford.nlp.trees.Tree构建树并像处理树一样处理它Nlp 如何处理我从syntaxnet获得的树?(conll格式),nlp,stanford-nlp,syntaxnet,Nlp,Stanford Nlp,Syntaxnet,我想我需要来自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 Sem
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构造树的建议。您想从conll文件加载语义图
import edu.stanford.nlp.trees.ud.ConLLUDocumentReader;
...
CoNLLUDocumentReader reader = new CoNLLUDocumentReader();
Iterator<SemanticGraph> it = reader.getIterator(IOUtils.readerFromString(conlluFile));
这将生成一个迭代器,为文件中的每个句子提供一个语义图
从依赖项解析生成选区树是一个开放的研究问题,因此据我所知,斯坦福大学CoreNLP目前没有办法做到这一点