【问题标题】:How to process tree that i got from syntaxnet?(conll format)如何处理我从语法网得到的树?(conll 格式)
【发布时间】:2017-04-05 03:37:04
【问题描述】:

我想我需要 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 中构造树的建议。

【问题讨论】:

    标签: nlp stanford-nlp syntaxnet


    【解决方案1】:

    您想从您的 CoNLL 文件中加载 SemanticGraph

    import edu.stanford.nlp.trees.ud.ConLLUDocumentReader;
    ...
    
    CoNLLUDocumentReader reader = new CoNLLUDocumentReader();
    Iterator<SemanticGraph> it = reader.getIterator(IOUtils.readerFromString(conlluFile));
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-02
      • 1970-01-01
      • 2013-09-13
      • 1970-01-01
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多