Transition-based Parsing 简介

来源:互联网 发布:mac 磁盘图标 名称 编辑:程序博客网 时间:2024/06/06 19:56

句法分析的几种主要方法:
Deterministic parsing(specifically : Transition-based parsing)
Dynamic programming(specifically : Graph-based parsing)
Constraint satisfaction

这里主要介绍一下Transition-based parsing
首先他所采取的数据结构是一个栈和一个队列。
Data structure:
Stack [… , wi ]S of partially processed tokens
Queue [wj , …]Q of remaining input tokens
然后还定义了一些列action
Parsing actions built from atomic actions:
Shift
Reduce

这种方法的优点是
Efficiency
Simplicity

其操作流程就是,根据栈和队列的状态,每次执行一个action,然后根据这个action就能改变栈和队列的状态,再根据现在栈和队列的状态来选取下一个action。如此循环下去就会得到一棵句法树。

Transition-based Dependency Parsing
input : Sentence:w1w2w3…..wn
output : Dependency parsed tree (三元组)
比如下面的树就可以用这样的三元组表示;:
(I,subj,like)
(fish,dobj,eating)
……
这里写图片描述

一般情况下:定义的action有下面这3个:
Shift
Left_arc
Right_arc
首先下图是其中的configuration,初始状态栈为空,队列保存了n个词。
这里写图片描述
来看看选择shift action后执行怎样的操作。
Push another word onto the top of the stack, i.e. shifting one token from the buffer to the stack.
这里写图片描述
做shift就是把队列的第一个词(booked)给放到栈中去,现在booked是栈顶,而 I 是栈顶下面的那个元素。

再来看看left-arc。
Pop the top two words from the stack. Attach the second to the first, creating an arc pointing to the left. Push the first word back on the stack.
这里写图片描述
形象点的看就是把栈顶的第2个元素依赖到栈顶的第一个元素上去,使他们只在栈中占一个位置。
用更好理解的说法就是,把栈顶的两个元素pop出去,然后把加一条booked指向I的边,这样表示I 依附于 booked,然后把booked push到栈中去。

right-arc是一个道理,加一条I指向booked的边,这样表示booked依附于I,然后把I push到栈中去。

HEN显然left-arc和right-arc只会操作栈顶的两个元素,加一条边,并留下其中的一个。

下面是完整的流程。
这里写图片描述

给一个更加详细的例子
这里写图片描述
来自Chen and Manning (2014)

下面说说成分
同样也是一个栈和一个队列。
几种action
SHIFT
REDUCE –unary–X (把栈顶节点归约成一个label为X的节点,并重新压入栈)
REDUCE –binary–{L/R}–X,(把栈顶的两个节点归约成一个label为X的节点,并入栈)
这里写图片描述
来自Global Discriminative Model (2009)

0 0
原创粉丝点击