【问题标题】:insert and delete transformation rules to typed dependency插入和删除转换规则到类型依赖
【发布时间】:2016-04-08 10:00:47
【问题描述】:

使用 stanford coreNLP,我提取了被动语态句子的所有类型依赖关系。现在我想让它成为主动语态。为此,我必须删除并在其中插入一些新规则。例如,如果我们采取类似的句子 “猫被狗追了。”那么类型化的依赖表示为: det(cat-2, The-1) nsubjpass(chased-4, cat-2) auxpass(追逐-4,是-3) det(dog-7, the-6) 特工(chased-4,dog-7) punct(chased-4, .-8)

将上述内容转换为主动语态的转换规则需要三个删除和两个插入: 1.匹配和删除: (a) nsubjpass(??X0, ??X1) (b) 辅助通道(??X0, ??X2) (c) 代理(??X0, ??X3)

  1. 插入: (a) nsubj(??X0, ??X3) (b) dobj(??X0, ??X1)

这里是??X0(chased)、??X1(cat)、??X2(was)和??X3(dog)

现在我的问题是如何在我的 java 代码中实现这些规则。

【问题讨论】:

    标签: java dependencies stanford-nlp


    【解决方案1】:

    所以你要换句:

    "The cat was chased by the dog."
    

    进入:

    "The dog chased the cat."
    

    ?

    如果我在做这个,我的第一反应是使用规则生成新的句子字符串,然后用该文本重建一个新的 Annotation 对象。

    所以我不会乱编辑图表或其他注释,我只会创建我想要的新字符串,然后重建依赖关系图。

    所以你可以想象有这样的规则:

    Pattern: X was VERB by Y --> Y <VERB> X
    Example: "The cat was chased by the dog." --> "The dog chased the cat."
    

    并遵循这个算法:

    1. 在依赖图中或使用正则表达式检测模式(在本例中为“是动词”)

    2. 创建 X 和 Y。因此您可以按照图表添加额外的单词,例如行列式。因此,在这种情况下,您将按照行列式将“cat”扩展为“The cat”,将“dog”扩展为“the dog”。

    3. 输出新更改的字符串:X Y,并将所有内容小写。在这种情况下输出“猫追狗”

    4. 然后将新句子的第一个单词大写并在末尾添加标点符号。导致“猫追狗”。

    5. 然后我只需将这个新字符串输入到 Annotation 中并重新运行管道以获得新的依赖关系图。

      Annotation newSentenceAnnotation = new Annotation("The dog chased the cat.");
      pipeline.annotate(newSentenceAnnotation);
      

    以下是一些使用语义图的链接:

    http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/semgraph/SemanticGraph.html

    http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/semgraph/SemanticGraphEdge.html

    如果你看一下我们最近发布的这个演示,有一个名为 DependencyMatchFinder.java 的类,它演示了从注解访问 SemanticGraph:

    https://github.com/stanfordnlp/nlp-meetup-demo/blob/master/DependencyMatchFinder.java

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      • 2014-04-25
      • 1970-01-01
      • 1970-01-01
      • 2015-09-29
      • 2014-06-09
      • 1970-01-01
      相关资源
      最近更新 更多