使用存储引理的节点生成斯坦福语义图 [英] Generating stanford semantic graph with nodes storing lemma

查看:98
本文介绍了使用存储引理的节点生成斯坦福语义图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试生成SemanticGraph并使用semgrex查找特定节点. 我想将引理用作semgrex中的节点属性之一.我在这里看到了一个相关的问题和答案:

I am trying to generate a SemanticGraph and use semgrex to find the specific node. I would like to use lemma as one of node attribute in semgrex. I saw a relevant question and answer here:

CoreNLP SemanticGraph-搜索具有特定引理的边

有人提到

确保节点存储了lemmas-请参阅CoreNLP的lemma注释器(当前仅适用于英语).

Make sure that the nodes are storing lemmas -- see the lemma annotator of CoreNLP (currently available for English, only).

当前,我可以使用管道生成所需的注释以生成语义图.

I current can use pipeline to generate the desired annotation to generate the semantic graph.

 Properties props = new Properties();
 props.put("annotators", "tokenize, ssplit, pos, lemma, parse");
 StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

但是,在搜索了相关信息之后,我只能在这里找到不推荐使用的函数:

However, after searching for relevant information, I only find a deprecated function at here:

https ://github.com/chbrown/nlp/blob/master/src/main/java/edu/stanford/nlp/pipeline/ParserAnnotatorUtils.java

public static SemanticGraph generateDependencies(Tree tree,
    boolean collapse,
    boolean ccProcess,
    boolean includeExtras,
    boolean lemmatize,
    boolean threadSafe) {
  SemanticGraph deps = SemanticGraphFactory.makeFromTree(tree, collapse, ccProcess, includeExtras, lemmatize, threadSafe);
  return deps;
}

似乎已从最新的coreNLP中删除.

which seemed to be removed from newest coreNLP.

任何人都可以对如何使用存储引理的节点生成语义图提供一些提示吗?

Could anyone give some hint on how to generate the semantic graph with nodes that storing the lemmas?

推荐答案

您所拥有的功能应该可以使用.引理将存储在由parse注释器生成的SemanticGraph中.您可以使用通过pipeline.annotate(Annotation)运行文本后检索图形:

The function as you have it should work. The lemmas will be stored in the SemanticGraph produced by the parse annotator. You can retrieve the graph after running your text through pipeline.annotate(Annotation) with:

sentence.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class)

或者,等效于Collapsed和CollapsedCCProcessed依赖项.请参见 http://www-nlp. stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/semgraph/SemanticGraphCoreAnnotations.html .请注意,这些内容附加在句子(CoreMap)上,而不附加在文档(Annotation)上.

Or, the equivalent for Collapsed and CollapsedCCProcessed dependencies. See http://www-nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/semgraph/SemanticGraphCoreAnnotations.html. Note that these are attached to a sentence (CoreMap), not a document (Annotation).

然后,您可以像往常一样在图形上运行Semgrex.例如{lemma:/foo/} >arctype {lemma:/bar/}.

You can then run Semgrex over the graph as usual; e.g., {lemma:/foo/} >arctype {lemma:/bar/}.

这篇关于使用存储引理的节点生成斯坦福语义图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆