首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何处理从syntaxnet获得的树?(conll格式)

如何处理从syntaxnet获得的树?(conll格式)
EN

Stack Overflow用户
提问于 2017-04-04 14:40:58
回答 1查看 273关注 0票数 3

我想我需要edu.stanford.nlp包中的Semgrex。对于这个任务,我需要从edu.stanford.nlp.trees.Tree构建树,并像这样处理该树

代码语言:javascript
复制
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构建树的建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-04 19:37:04

您希望从您的SemanticGraph文件中加载一个CoNLL。

代码语言:javascript
复制
import edu.stanford.nlp.trees.ud.ConLLUDocumentReader;
...

CoNLLUDocumentReader reader = new CoNLLUDocumentReader();
Iterator<SemanticGraph> it = reader.getIterator(IOUtils.readerFromString(conlluFile));

这将产生一个Iterator,为您的文件中的每个句子提供一个SemanticGraph

从依赖分析中生成一个选区树是一个开放的研究问题,因此斯坦福大学CoreNLP目前无法做到这一点,据我所知。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43210411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档