Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
Toy-MT-Introduction
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
单韦乔
Toy-MT-Introduction
Commits
c36bc0ad
Commit
c36bc0ad
authored
Jan 12, 2020
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree matching
parent
af19426a
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
367 行增加
和
38 行删除
+367
-38
Section04-Phrasal-and-Syntactic-Models/section04-test.tex
+168
-38
Section04-Phrasal-and-Syntactic-Models/section04.tex
+199
-0
没有找到文件。
Section04-Phrasal-and-Syntactic-Models/section04-test.tex
查看文件 @
c36bc0ad
...
...
@@ -152,68 +152,198 @@
\subsection
{
规则匹配
}
%%%------------------------------------------------------------------------------------------------------------
%%% 基于树的解码方法 - chart
\begin{frame}
{
基于树的解码 -
chart
}
%%% 基于树的解码方法 - chart
-based decoding
\begin{frame}
{
基于树的解码 -
基于chart的方法
}
\begin{itemize}
\item
规则匹配后形成的超图,每个节点可以由两部分信息决定:节点的句法标记 + 跨度
\item
基于chart这种结构,可以很容易的构建解码所用的超图。常用的方法是自底向上解码:
\begin{itemize}
\item
这本质上和单语句法分析中的表示方法是一致的
\item
存储形式有很多中,这里采用常用的chart结构,即,用一个二维表存储,其中每一个单元对应一个跨度(span)。同一个跨度的节点都可以放到同一个表单元中,同一表单元的节点用句法标记区分
\item
从源语言句法树的叶子节点开始,自下而上访问树的节点
\item
对于每个跨度,如果对应一个树节点,则匹配相应的规则
\item
从树的根节点可以得到翻译推导,最终选择最优推导所对应的译文输出
\end{itemize}
\end{itemize}
\visible
<2->
{
\begin{minipage}
[b]
{
0.42
\linewidth
}
\begin{center}
\begin{tikzpicture}
\visible
<2->
{
\begin{scope}
\node
[anchor=west,circle,inner sep=2pt,draw,fill=red!20] (node1) at (0,0)
{
\tiny
{
[1,1]
}}
;
\node
[anchor=west,circle,inner sep=2pt,draw,fill=blue!20] (node2) at ([xshift=3.3em]node1.east)
{
\tiny
{
[3,3]
}}
;
\node
[anchor=north,circle,inner sep=2pt,draw,fill=green!20] (node3) at ([xshift=2.5em,yshift=5em]node1.north)
{
\tiny
{
[1,3]
}}
;
\node
[anchor=north] (rulelabel) at ([yshift=-0.5em,xshift=2em]node1.south east)
{
\tiny
{
规则
$
r
$
所对应的超图
}}
;
\tikzstyle
{
chartnode
}
=[rectangle,minimum size=1.3em,draw]
\node
[chartnode,anchor=north west] (cell11) at (0,0)
{}
;
\node
[chartnode,anchor=north west] (cell21) at ([yshift=-0em]cell11.south west)
{}
;
\node
[chartnode,anchor=west] (cell22) at (cell21.east)
{}
;
\node
[chartnode,anchor=north west] (cell31) at ([yshift=-0em]cell21.south west)
{}
;
\node
[chartnode,anchor=west] (cell32) at (cell31.east)
{}
;
\node
[chartnode,anchor=west] (cell33) at (cell32.east)
{}
;
\node
[chartnode,anchor=north west] (cell41) at ([yshift=-0em]cell31.south west)
{}
;
\node
[chartnode,anchor=west] (cell42) at (cell41.east)
{}
;
\node
[chartnode,anchor=west] (cell43) at (cell42.east)
{}
;
\node
[chartnode,anchor=west] (cell44) at (cell43.east)
{}
;
\tikzstyle
{
chartnode2
}
=[rectangle,minimum size=1.3em,fill=orange!20]
\node
<3-> [chartnode2,anchor=north west] (cell11) at (0,0)
{}
;
\node
<4-> [chartnode2,anchor=north west] (cell21) at ([yshift=-0em]cell11.south west)
{}
;
\node
<7-> [chartnode2,anchor=west] (cell22) at (cell21.east)
{}
;
\node
<5-> [chartnode2,anchor=north west] (cell31) at ([yshift=-0em]cell21.south west)
{}
;
\node
<8-> [chartnode2,anchor=west] (cell32) at (cell31.east)
{}
;
\node
<10-> [chartnode2,anchor=west] (cell33) at (cell32.east)
{}
;
\node
<6-> [chartnode2,anchor=north west] (cell41) at ([yshift=-0em]cell31.south west)
{}
;
\node
<9-> [chartnode2,anchor=west] (cell42) at (cell41.east)
{}
;
\node
<11-> [chartnode2,anchor=west] (cell43) at (cell42.east)
{}
;
\node
<12-> [chartnode2,anchor=west] (cell44) at (cell43.east)
{}
;
\node
[anchor=east] (s1) at (cell11.west)
{
\scriptsize
{
猫
}}
;
\node
[anchor=east] (s2) at (cell21.west)
{
\scriptsize
{
喜欢
}}
;
\node
[anchor=east] (s3) at (cell31.west)
{
\scriptsize
{
吃
}}
;
\node
[anchor=east] (s4) at (cell41.west)
{
\scriptsize
{
鱼
}}
;
\node
[anchor=north] (t5) at (cell41.south)
{
\tiny
{$
l
$
=1
}}
;
\node
[anchor=north] (t5) at (cell42.south)
{
\tiny
{$
l
$
=2
}}
;
\node
[anchor=north] (t5) at (cell43.south)
{
\tiny
{$
l
$
=3
}}
;
\node
[anchor=north] (t5) at (cell44.south)
{
\tiny
{$
l
$
=4
}}
;
\node
[anchor=north] (chartlabel) at ([yshift=-1em]cell42.south east)
{
\footnotesize
{
\textbf
{
chart
}}}
;
\node
[anchor=north west] (w1) at ([yshift=-2.5em,xshift=-2.0em]cell41.south west)
{
猫
}
;
\node
[anchor=west] (w2) at ([xshift=0.3em]w1.east)
{
喜欢
}
;
\node
[anchor=west] (w3) at ([xshift=0.3em]w2.east)
{
吃
}
;
\node
[anchor=west] (w4) at ([xshift=0.3em]w3.east)
{
鱼
}
;
\node
[anchor=north east] (p0) at ([xshift=0.3em]w1.south west)
{
\blue
{
0
}}
;
\node
[anchor=north east] (p1) at ([xshift=0.3em]w2.south west)
{
\blue
{
1
}}
;
\node
[anchor=north east] (p2) at ([xshift=0.3em]w3.south west)
{
\blue
{
2
}}
;
\node
[anchor=north east] (p3) at ([xshift=0.3em]w4.south west)
{
\blue
{
3
}}
;
\node
[anchor=north west] (p4) at ([xshift=-0.4em]w4.south east)
{
\blue
{
4
}}
;
\node
[anchor=north] (slabel) at (p2.south)
{
\scriptsize
{
\textbf
{
源语言句子
}}}
;
\draw
[-latex] (node1.90) ..controls +(north:3em) and +(south:3em).. (node3.-90);
\draw
[-latex] (node2.90) ..controls +(north:3em) and +(south:3em).. (node3.-90);
\end{scope}
\node
[anchor=west] (rule1) at ([xshift=6em]node3.east)
{
\footnotesize
{
VP(AD
$_
1
$
VP(VV(下降)) AS
$_
2
$
)
}}
;
\node
[anchor=north west] (rule2) at (rule1.south west)
{
\footnotesize
{$
\to
$
AS
$_
2
$
AD
$_
1
$
fallen
}}
;
\node
[anchor=south] (rulelabel) at ([yshift=-0.4em]rule1.north)
{
\tiny
{
规则
$
r
$}}
;
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}
[b]
{
0.55
\linewidth
}
{
\footnotesize
\visible
<3->
{
\begin{tabular}
{
l l l l
}
\visible
<3->
{
序号
}
&
\visible
<3->
{
跨度
}
&
\visible
<3->
{
标记
}
&
\visible
<3->
{
源语句子片段
}
\\
\hline
\visible
<3->
{
1
}
&
\visible
<3->
{
[
{
\blue
0
}
,
{
\blue
1
}
]
}
&
\visible
<3->
{
NN
\&
NP
}
&
\visible
<3->
{
猫
}
\\
\visible
<4->
{
2
}
&
\visible
<4->
{
[
{
\blue
1
}
,
{
\blue
2
}
]
}
&
\visible
<4->
{
VV
}
&
\visible
<4->
{
喜欢
}
\\
\visible
<5->
{
3
}
&
\visible
<5->
{
[
{
\blue
2
}
,
{
\blue
5
}
]
}
&
\visible
<5->
{
VV
}
&
\visible
<5->
{
吃
}
\\
\visible
<6->
{
4
}
&
\visible
<6->
{
[
{
\blue
3
}
,
{
\blue
6
}
]
}
&
\visible
<6->
{
NN
\&
NP
}
&
\visible
<6->
{
鱼
}
\\
\visible
<7->
{
5
}
&
\visible
<7->
{
[
{
\blue
0
}
,
{
\blue
2
}
]
}
&
\visible
<7->
{
N/A
}
&
\visible
<7->
{
猫 喜欢
}
\\
\visible
<8->
{
6
}
&
\visible
<8->
{
[
{
\blue
1
}
,
{
\blue
3
}
]
}
&
\visible
<8->
{
N/A
}
&
\visible
<8->
{
喜欢 吃
}
\\
\visible
<9->
{
7
}
&
\visible
<9->
{
[
{
\blue
2
}
,
{
\blue
4
}
]
}
&
\visible
<9->
{
VP
}
&
\visible
<9->
{
吃 鱼
}
\\
\visible
<10->
{
8
}
&
\visible
<10->
{
[
{
\blue
0
}
,
{
\blue
3
}
]
}
&
\visible
<10->
{
N/A
}
&
\visible
<10->
{
猫 喜欢 吃
}
\\
\visible
<11->
{
9
}
&
\visible
<11->
{
[
{
\blue
1
}
,
{
\blue
4
}
]
}
&
\visible
<11->
{
VP
}
&
\visible
<11->
{
喜欢 吃 鱼
}
\\
\visible
<12->
{
10
}
&
\visible
<12->
{
[
{
\blue
0
}
,
{
\blue
4
}
]
}
&
\visible
<12->
{
IP (
\alert
{
root
}
)
}
&
\visible
<12->
{
猫 喜欢 吃 鱼
}
\\
\\
\end{tabular}
}
}
\end{minipage}
}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 规则使用 - 基于树的匹配
\begin{frame}
{
使用树结构匹配树到串规则
}
\begin{itemize}
\item
对于规则的源语言部分,可以使用树片段的匹配找到可以使用这条规则位置
\begin{itemize}
\item
匹配的规则会被存入相应的表格单元中
\end{itemize}
\end{itemize}
\vspace
{
-2em
}
\begin{center}
\begin{tikzpicture}
\begin{scope}
{
\scriptsize
\begin{scope}
[sibling distance=2pt,level distance=20pt,grow'=up]
\Tree
[.
\node
(treeroot)
{
IP
}
;
[.NP [.NR 阿都拉
$_
1
$
]]
[.
\node
(tn1)
{
VP
}
;
[.
\node
(tn2)
{
PP
}
;
[.
\node
(tn3)
{
P
}
;
\node
(cw1)
{
对
$_
2
$}
; ]
[.
\node
(tn4)
{
NP
}
;
\edge
[roof]
;
{
自己
$_
3
$
四
$_
4
$
\
个
$_
5
$
\
多
$_
6
$
\
月
$_
7
$
\
以来
$_
8
$
\
的
$_
9
$
\
施政
$_{
10
}$
\
表现
$_{
11
}$}
]
]
[.
\node
(tn5)
{
VP
}
;
[.VV 感到
$_{
12
}$
]
[.NN 满意
$_{
13
}$
]
]
]
]
\end{scope}
\visible
<2->
{
\node
[anchor=west,fill=green!20!white] (rulepart1) at ([yshift=2.0in,xshift=-1.3in]treeroot.east)
{
VP(PP(P(对) NP
$_
1
$
) VP
$_
2
$
)
}
;
\node
[anchor=north west] (rulepart2) at (rulepart1.south west)
{$
\to
$
VP
$_
2
$
with NP
$_
1
$}
;
}
\begin{pgfonlayer}
{
background
}
\visible
<2->
{
\node
[anchor=north west,fill=green!20,inner sep=2pt,minimum height=1.5em,minimum width=1.3em] (nodebox1) at ([xshift=0.2em]rule1.north west)
{}
;
\node
[anchor=north west,fill=red!20,inner sep=2pt,minimum height=1.5em,minimum width=1.8em] (nodebox2) at ([xshift=0.2em]nodebox1.north east)
{}
;
\node
[anchor=north east,fill=blue!20,inner sep=2pt,minimum height=1.5em,minimum width=1.6em] (nodebox1) at ([xshift=-0.6em]rule1.north east)
{}
;
\node
[rectangle,draw,inner sep=2pt]
[fit = (rulepart1) (rulepart2)] (rulemark)
{}
;
}
\end{pgfonlayer}
\tikzstyle
{
chartnode
}
=[rectangle,minimum size=1.3em,draw]
\node
[chartnode,anchor=north west] (cell11) at ([yshift=-2em]rule2.south west)
{}
;
\node
[chartnode,anchor=north west] (cell21) at ([yshift=-0em]cell11.south west)
{}
;
\node
[chartnode,anchor=west] (cell22) at (cell21.east)
{}
;
\node
[chartnode,anchor=north west] (cell31) at ([yshift=-0em]cell21.south west)
{}
;
\node
[chartnode,anchor=west] (cell32) at (cell31.east)
{}
;
\node
[chartnode,anchor=west] (cell33) at (cell32.east)
{}
;
\node
[anchor=north] (chartlabel) at (cell32.south)
{
\scriptsize
{
chart
}}
;
\visible
<2->
{
\node
[anchor=south west] at (rulemark.north west)
{
\tiny
{
\textbf
{
树到串翻译规则
}}}
;
}
}
\begin{scope}
[xshift=1.5in,yshift=1.6in]
\visible
<3->
{
\node
[anchor=center, minimum size=10pt,draw]
(cell1and1) at (0,0)
{}
;
\node
[anchor=center, minimum size=10pt,draw]
(cell2and1) at ([xshift=10pt]cell1and1.center)
{}
;
\node
[anchor=center, minimum size=10pt,draw]
(cell3and1) at ([xshift=10pt]cell2and1.center)
{}
;
\node
[anchor=center, minimum size=10pt]
(cell4and1) at ([xshift=15pt]cell3and1.center)
{
\tiny
{$
\dots
$}}
;
\node
[anchor=center, minimum size=10pt,draw]
(cellnand1) at ([xshift=13pt]cell4and1.center)
{}
;
\node
[anchor=center, minimum size=10pt,draw]
(cell1and2) at ([yshift=10pt]cell1and1.center)
{}
;
\node
[anchor=center, minimum size=10pt,draw]
(cell2and2) at ([xshift=10pt]cell1and2.center)
{}
;
\node
[anchor=center, minimum size=10pt,draw]
(cell1and3) at ([yshift=10pt]cell1and2.center)
{}
;
\node
[anchor=center, minimum size=10pt]
(cell1and4) at ([yshift=20pt]cell1and3.center)
{
\tiny
{$
\vdots
$}}
;
\node
[anchor=center, minimum size=10pt]
(cell2and3) at ([yshift=20pt]cell2and2.center)
{
\tiny
{$
\vdots
$}}
;
\node
[anchor=center, minimum size=10pt]
(cell3and2) at ([yshift=20pt]cell3and1.center)
{
\tiny
{$
\vdots
$}}
;
\node
[anchor=center, minimum size=10pt,draw]
(cell4andn) at ([yshift=20pt,xshift=10pt]cell3and1.center)
{}
;
%\node[anchor=center, minimum size=10pt] (cell4and2) at ([yshift=20pt]cell4and1.center) {\tiny{$\ddots$}};
\node
[anchor=center, minimum size=10pt,draw]
(cell1andn) at ([yshift=10pt]cell1and4.center)
{}
;
\node
[anchor=center, minimum size=10pt,draw]
(cell2andn) at ([xshift=10pt,yshift=-10pt]cell1andn.center)
{}
;
%\node[anchor=center, minimum size=10pt,draw] (cell3andn) at ([xshift=10pt,yshift=-10pt]cell2andn.center) {};
\node
[anchor=west]
(chartlabel) at ([xshift=-0em,yshift=-0.8em]cell1and1.south east)
{
\scriptsize
{
Chart
}}
;
}
\end{scope}
\visible
<3->
{
\node
[chartnode,anchor=north west,fill=red!20] (cell11) at ([yshift=-2em]rule2.south west)
{}
;
\node
[chartnode,anchor=north west,fill=blue!20] (cell31) at ([yshift=-0em]cell21.south west)
{}
;
\node
[chartnode,anchor=west,fill=green!20] (cell33) at (cell32.east)
{}
;
\draw
[<-,dotted,thick] ([xshift=0.1em]node3.60) ..controls +(60:0.5) and +(120:0.5).. (rule1.north west);
\draw
[->,dotted] ([xshift=0.1em]node3.-60)..controls +(-60:3em) and +(north:7em).. (cell33.center);
\draw
[->,dotted] ([xshift=0.1em]node2.0)..controls +(east:2em) and +(west:3em).. (cell31.center);
\draw
[->,dotted] ([xshift=0.1em]node1.60)..controls +(60:1.5em) and +(120:2em).. (cell11.center);
\path
[draw,thick,blue,->,dashed] (rulemark.north east) .. controls +(60:2.0) and +(north east:1.5) .. ([yshift=0.05em,xshift=0.05em]cell4andn.north east) node[pos=0.25, below,yshift=-0.2em] (spanlabel)
{}
;
}
\visible
<4->
{
\node
[anchor=north west,fill=green!20,drop shadow,align=left] (cellbox) at ([yshift=4em,xshift=1em]cell33.north east)
{
\scriptsize
{
表单元表示覆盖单词1-3的跨度
}
\\\scriptsize
{
保存跨度[1,3]上的所有节点
}
\\\scriptsize
{
VP [1,3]
}
\\\scriptsize
{
NP [1,3]
}
\\\scriptsize
{
...
}}
;
\draw
[->] ([xshift=-0.2em,yshift=-0.2em]cell33.north east)..controls +(north:2.5em) and +(west:1em).. ([yshift=2em]cellbox.west);
\begin{pgfonlayer}
{
background
}
\visible
<2->
{
\path
[fill=green!20] (tn1.south west) -- ([yshift=0.2em]tn2.south west) -- ([yshift=0.2em,xshift=-0.30em]tn3.south west) -- (cw1.north west) -- (cw1.north east) -- ([xshift=0.30em]tn3.north east) -- (tn4.north east) -- (tn4.south east) -- ([xshift=0.5em]tn2.north east) -- (tn5.north east)-- ([yshift=0.2em]tn5.south east) -- (tn1.south east) -- (tn1.south west);
}
\end{pgfonlayer}
\visible
<2->
{
\path
[draw,thick,blue,<->] ([xshift=-2em]rulepart1.south east) .. controls +(south:1.7) and +(north:1.3) .. ([xshift=0em,yshift=0.10em]cw1.north) node[pos=0.5, below,xshift=0.3in]
{
\scriptsize
{
树片段的匹配
}}
;
}
\end{scope}
}
\end{tikzpicture}
\end{center}
...
...
Section04-Phrasal-and-Syntactic-Models/section04.tex
查看文件 @
c36bc0ad
...
...
@@ -4609,6 +4609,205 @@ NP-BAR(NN$_1$ NP-BAR$_2$) $\to$ NN$_1$ NP-BAR$_2$
\end
{
frame
}
%%%------------------------------------------------------------------------------------------------------------
%%% 基于树的解码方法 - chart-based decoding
\begin
{
frame
}{
基于树的解码
-
基于chart的方法
}
\begin
{
itemize
}
\item
基于chart这种结构,可以很容易的构建解码所用的超图。常用的方法是自底向上解码:
\begin
{
itemize
}
\item
从源语言句法树的叶子节点开始,自下而上访问树的节点
\item
对于每个跨度,如果对应一个树节点,则匹配相应的规则
\item
从树的根节点可以得到翻译推导,最终选择最优推导所对应的译文输出
\end
{
itemize
}
\end
{
itemize
}
\visible
<
2
-
>
{
\begin
{
minipage
}
[
b
]
{
0
.
42
\linewidth
}
\begin
{
center
}
\begin
{
tikzpicture
}
\begin
{
scope
}
\tikzstyle
{
chartnode
}
=[
rectangle,minimum size
=
1
.
3
em,draw
]
\node
[
chartnode,anchor
=
north west
]
(
cell
11
)
at
(
0
,
0
)
{}
;
\node
[
chartnode,anchor
=
north west
]
(
cell
21
)
at
([
yshift
=-
0
em
]
cell
11
.south west
)
{}
;
\node
[
chartnode,anchor
=
west
]
(
cell
22
)
at
(
cell
21
.east
)
{}
;
\node
[
chartnode,anchor
=
north west
]
(
cell
31
)
at
([
yshift
=-
0
em
]
cell
21
.south west
)
{}
;
\node
[
chartnode,anchor
=
west
]
(
cell
32
)
at
(
cell
31
.east
)
{}
;
\node
[
chartnode,anchor
=
west
]
(
cell
33
)
at
(
cell
32
.east
)
{}
;
\node
[
chartnode,anchor
=
north west
]
(
cell
41
)
at
([
yshift
=-
0
em
]
cell
31
.south west
)
{}
;
\node
[
chartnode,anchor
=
west
]
(
cell
42
)
at
(
cell
41
.east
)
{}
;
\node
[
chartnode,anchor
=
west
]
(
cell
43
)
at
(
cell
42
.east
)
{}
;
\node
[
chartnode,anchor
=
west
]
(
cell
44
)
at
(
cell
43
.east
)
{}
;
\tikzstyle
{
chartnode
2
}
=[
rectangle,minimum size
=
1
.
3
em,fill
=
orange
!
20
]
\node
<
3
-
>
[
chartnode
2
,anchor
=
north west
]
(
cell
11
)
at
(
0
,
0
)
{}
;
\node
<
4
-
>
[
chartnode
2
,anchor
=
north west
]
(
cell
21
)
at
([
yshift
=-
0
em
]
cell
11
.south west
)
{}
;
\node
<
7
-
>
[
chartnode
2
,anchor
=
west
]
(
cell
22
)
at
(
cell
21
.east
)
{}
;
\node
<
5
-
>
[
chartnode
2
,anchor
=
north west
]
(
cell
31
)
at
([
yshift
=-
0
em
]
cell
21
.south west
)
{}
;
\node
<
8
-
>
[
chartnode
2
,anchor
=
west
]
(
cell
32
)
at
(
cell
31
.east
)
{}
;
\node
<
10
-
>
[
chartnode
2
,anchor
=
west
]
(
cell
33
)
at
(
cell
32
.east
)
{}
;
\node
<
6
-
>
[
chartnode
2
,anchor
=
north west
]
(
cell
41
)
at
([
yshift
=-
0
em
]
cell
31
.south west
)
{}
;
\node
<
9
-
>
[
chartnode
2
,anchor
=
west
]
(
cell
42
)
at
(
cell
41
.east
)
{}
;
\node
<
11
-
>
[
chartnode
2
,anchor
=
west
]
(
cell
43
)
at
(
cell
42
.east
)
{}
;
\node
<
12
-
>
[
chartnode
2
,anchor
=
west
]
(
cell
44
)
at
(
cell
43
.east
)
{}
;
\node
[
anchor
=
east
]
(
s
1
)
at
(
cell
11
.west
)
{
\scriptsize
{
猫
}}
;
\node
[
anchor
=
east
]
(
s
2
)
at
(
cell
21
.west
)
{
\scriptsize
{
喜欢
}}
;
\node
[
anchor
=
east
]
(
s
3
)
at
(
cell
31
.west
)
{
\scriptsize
{
吃
}}
;
\node
[
anchor
=
east
]
(
s
4
)
at
(
cell
41
.west
)
{
\scriptsize
{
鱼
}}
;
\node
[
anchor
=
north
]
(
t
5
)
at
(
cell
41
.south
)
{
\tiny
{$
l
$
=
1
}}
;
\node
[
anchor
=
north
]
(
t
5
)
at
(
cell
42
.south
)
{
\tiny
{$
l
$
=
2
}}
;
\node
[
anchor
=
north
]
(
t
5
)
at
(
cell
43
.south
)
{
\tiny
{$
l
$
=
3
}}
;
\node
[
anchor
=
north
]
(
t
5
)
at
(
cell
44
.south
)
{
\tiny
{$
l
$
=
4
}}
;
\node
[
anchor
=
north
]
(
chartlabel
)
at
([
yshift
=-
1
em
]
cell
42
.south east
)
{
\footnotesize
{
\textbf
{
chart
}}}
;
\node
[
anchor
=
north west
]
(
w
1
)
at
([
yshift
=-
2
.
5
em,xshift
=-
2
.
0
em
]
cell
41
.south west
)
{
猫
}
;
\node
[
anchor
=
west
]
(
w
2
)
at
([
xshift
=
0
.
3
em
]
w
1
.east
)
{
喜欢
}
;
\node
[
anchor
=
west
]
(
w
3
)
at
([
xshift
=
0
.
3
em
]
w
2
.east
)
{
吃
}
;
\node
[
anchor
=
west
]
(
w
4
)
at
([
xshift
=
0
.
3
em
]
w
3
.east
)
{
鱼
}
;
\node
[
anchor
=
north east
]
(
p
0
)
at
([
xshift
=
0
.
3
em
]
w
1
.south west
)
{
\blue
{
0
}}
;
\node
[
anchor
=
north east
]
(
p
1
)
at
([
xshift
=
0
.
3
em
]
w
2
.south west
)
{
\blue
{
1
}}
;
\node
[
anchor
=
north east
]
(
p
2
)
at
([
xshift
=
0
.
3
em
]
w
3
.south west
)
{
\blue
{
2
}}
;
\node
[
anchor
=
north east
]
(
p
3
)
at
([
xshift
=
0
.
3
em
]
w
4
.south west
)
{
\blue
{
3
}}
;
\node
[
anchor
=
north west
]
(
p
4
)
at
([
xshift
=-
0
.
4
em
]
w
4
.south east
)
{
\blue
{
4
}}
;
\node
[
anchor
=
north
]
(
slabel
)
at
(
p
2
.south
)
{
\scriptsize
{
\textbf
{
源语言句子
}}}
;
\end
{
scope
}
\end
{
tikzpicture
}
\end
{
center
}
\end
{
minipage
}
\begin
{
minipage
}
[
b
]
{
0
.
55
\linewidth
}
{
\footnotesize
\visible
<
3
-
>
{
\begin
{
tabular
}{
l l l l
}
\visible
<
3
-
>
{
序号
}
&
\visible
<
3
-
>
{
跨度
}
&
\visible
<
3
-
>
{
标记
}
&
\visible
<
3
-
>
{
源语句子片段
}
\\
\hline
\visible
<
3
-
>
{
1
}
&
\visible
<
3
-
>
{
[
{
\blue
0
}
,
{
\blue
1
}
]
}
&
\visible
<
3
-
>
{
NN
\&
NP
}
&
\visible
<
3
-
>
{
猫
}
\\
\visible
<
4
-
>
{
2
}
&
\visible
<
4
-
>
{
[
{
\blue
1
}
,
{
\blue
2
}
]
}
&
\visible
<
4
-
>
{
VV
}
&
\visible
<
4
-
>
{
喜欢
}
\\
\visible
<
5
-
>
{
3
}
&
\visible
<
5
-
>
{
[
{
\blue
2
}
,
{
\blue
5
}
]
}
&
\visible
<
5
-
>
{
VV
}
&
\visible
<
5
-
>
{
吃
}
\\
\visible
<
6
-
>
{
4
}
&
\visible
<
6
-
>
{
[
{
\blue
3
}
,
{
\blue
6
}
]
}
&
\visible
<
6
-
>
{
NN
\&
NP
}
&
\visible
<
6
-
>
{
鱼
}
\\
\visible
<
7
-
>
{
5
}
&
\visible
<
7
-
>
{
[
{
\blue
0
}
,
{
\blue
2
}
]
}
&
\visible
<
7
-
>
{
N
/
A
}
&
\visible
<
7
-
>
{
猫 喜欢
}
\\
\visible
<
8
-
>
{
6
}
&
\visible
<
8
-
>
{
[
{
\blue
1
}
,
{
\blue
3
}
]
}
&
\visible
<
8
-
>
{
N
/
A
}
&
\visible
<
8
-
>
{
喜欢 吃
}
\\
\visible
<
9
-
>
{
7
}
&
\visible
<
9
-
>
{
[
{
\blue
2
}
,
{
\blue
4
}
]
}
&
\visible
<
9
-
>
{
VP
}
&
\visible
<
9
-
>
{
吃 鱼
}
\\
\visible
<
10
-
>
{
8
}
&
\visible
<
10
-
>
{
[
{
\blue
0
}
,
{
\blue
3
}
]
}
&
\visible
<
10
-
>
{
N
/
A
}
&
\visible
<
10
-
>
{
猫 喜欢 吃
}
\\
\visible
<
11
-
>
{
9
}
&
\visible
<
11
-
>
{
[
{
\blue
1
}
,
{
\blue
4
}
]
}
&
\visible
<
11
-
>
{
VP
}
&
\visible
<
11
-
>
{
喜欢 吃 鱼
}
\\
\visible
<
12
-
>
{
10
}
&
\visible
<
12
-
>
{
[
{
\blue
0
}
,
{
\blue
4
}
]
}
&
\visible
<
12
-
>
{
IP
(
\alert
{
root
}
)
}
&
\visible
<
12
-
>
{
猫 喜欢 吃 鱼
}
\\
\\
\end
{
tabular
}
}
}
\end
{
minipage
}
}
\end
{
frame
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 规则使用 - 基于树的匹配
\begin
{
frame
}{
使用树结构匹配树到串规则
}
\begin
{
itemize
}
\item
对于规则的源语言部分,可以使用树片段的匹配找到可以使用这条规则位置
\begin
{
itemize
}
\item
匹配的规则会被存入相应的表格单元中
\end
{
itemize
}
\end
{
itemize
}
\vspace
{
-
2
em
}
\begin
{
center
}
\begin
{
tikzpicture
}
\begin
{
scope
}
{
\scriptsize
\begin
{
scope
}
[
sibling distance
=
2
pt,level distance
=
20
pt,grow'
=
up
]
\Tree
[
.
\node
(
treeroot
)
{
IP
}
;
[
.NP
[
.NR 阿都拉
$_
1
$
]]
[
.
\node
(
tn
1
)
{
VP
}
;
[
.
\node
(
tn
2
)
{
PP
}
;
[
.
\node
(
tn
3
)
{
P
}
;
\node
(
cw
1
)
{
对
$_
2
$}
;
]
[
.
\node
(
tn
4
)
{
NP
}
;
\edge
[
roof
]
;
{
自己
$_
3
$
四
$_
4
$
\
个
$_
5
$
\
多
$_
6
$
\
月
$_
7
$
\
以来
$_
8
$
\
的
$_
9
$
\
施政
$_{
10
}$
\
表现
$_{
11
}$}
]
]
[
.
\node
(
tn
5
)
{
VP
}
;
[
.VV 感到
$_{
12
}$
]
[
.NN 满意
$_{
13
}$
]
]
]
]
\end
{
scope
}
\visible
<
2
-
>
{
\node
[
anchor
=
west,fill
=
green
!
20
!
white
]
(
rulepart
1
)
at
([
yshift
=
2
.
0
in,xshift
=-
1
.
3
in
]
treeroot.east
)
{
VP
(
PP
(
P
(
对
)
NP
$_
1
$
)
VP
$_
2
$
)
}
;
\node
[
anchor
=
north west
]
(
rulepart
2
)
at
(
rulepart
1
.south west
)
{$
\to
$
VP
$_
2
$
with NP
$_
1
$}
;
}
\begin
{
pgfonlayer
}{
background
}
\visible
<
2
-
>
{
\node
[
rectangle,draw,inner sep
=
2
pt
]
[
fit
=
(
rulepart
1
)
(
rulepart
2
)]
(
rulemark
)
{}
;
}
\end
{
pgfonlayer
}
\visible
<
2
-
>
{
\node
[
anchor
=
south west
]
at
(
rulemark.north west
)
{
\tiny
{
\textbf
{
树到串翻译规则
}}}
;
}
}
\begin
{
scope
}
[
xshift
=
1
.
5
in,yshift
=
1
.
6
in
]
\visible
<
3
-
>
{
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
1
and
1
)
at
(
0
,
0
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
2
and
1
)
at
([
xshift
=
10
pt
]
cell
1
and
1
.center
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
3
and
1
)
at
([
xshift
=
10
pt
]
cell
2
and
1
.center
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt
]
(
cell
4
and
1
)
at
([
xshift
=
15
pt
]
cell
3
and
1
.center
)
{
\tiny
{$
\dots
$}}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cellnand
1
)
at
([
xshift
=
13
pt
]
cell
4
and
1
.center
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
1
and
2
)
at
([
yshift
=
10
pt
]
cell
1
and
1
.center
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
2
and
2
)
at
([
xshift
=
10
pt
]
cell
1
and
2
.center
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
1
and
3
)
at
([
yshift
=
10
pt
]
cell
1
and
2
.center
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt
]
(
cell
1
and
4
)
at
([
yshift
=
20
pt
]
cell
1
and
3
.center
)
{
\tiny
{$
\vdots
$}}
;
\node
[
anchor
=
center, minimum size
=
10
pt
]
(
cell
2
and
3
)
at
([
yshift
=
20
pt
]
cell
2
and
2
.center
)
{
\tiny
{$
\vdots
$}}
;
\node
[
anchor
=
center, minimum size
=
10
pt
]
(
cell
3
and
2
)
at
([
yshift
=
20
pt
]
cell
3
and
1
.center
)
{
\tiny
{$
\vdots
$}}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
4
andn
)
at
([
yshift
=
20
pt,xshift
=
10
pt
]
cell
3
and
1
.center
)
{}
;
%\node[anchor=center, minimum size=10pt] (cell4and2) at ([yshift=20pt]cell4and1.center) {\tiny{$\ddots$}};
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
1
andn
)
at
([
yshift
=
10
pt
]
cell
1
and
4
.center
)
{}
;
\node
[
anchor
=
center, minimum size
=
10
pt,draw
]
(
cell
2
andn
)
at
([
xshift
=
10
pt,yshift
=-
10
pt
]
cell
1
andn.center
)
{}
;
%\node[anchor=center, minimum size=10pt,draw] (cell3andn) at ([xshift=10pt,yshift=-10pt]cell2andn.center) {};
\node
[
anchor
=
west
]
(
chartlabel
)
at
([
xshift
=-
0
em,yshift
=-
0
.
8
em
]
cell
1
and
1
.south east
)
{
\scriptsize
{
Chart
}}
;
}
\end
{
scope
}
\visible
<
3
-
>
{
\path
[
draw,thick,blue,
-
>,dashed
]
(
rulemark.north east
)
.. controls
+(
60
:
2
.
0
)
and
+(
north east:
1
.
5
)
..
([
yshift
=
0
.
05
em,xshift
=
0
.
05
em
]
cell
4
andn.north east
)
node
[
pos
=
0
.
25
, below,yshift
=-
0
.
2
em
]
(
spanlabel
)
{}
;
}
\begin
{
pgfonlayer
}{
background
}
\visible
<
2
-
>
{
\path
[
fill
=
green
!
20
]
(
tn
1
.south west
)
--
([
yshift
=
0
.
2
em
]
tn
2
.south west
)
--
([
yshift
=
0
.
2
em,xshift
=-
0
.
30
em
]
tn
3
.south west
)
--
(
cw
1
.north west
)
--
(
cw
1
.north east
)
--
([
xshift
=
0
.
30
em
]
tn
3
.north east
)
--
(
tn
4
.north east
)
--
(
tn
4
.south east
)
--
([
xshift
=
0
.
5
em
]
tn
2
.north east
)
--
(
tn
5
.north east
)--
([
yshift
=
0
.
2
em
]
tn
5
.south east
)
--
(
tn
1
.south east
)
--
(
tn
1
.south west
)
;
}
\end
{
pgfonlayer
}
\visible
<
2
-
>
{
\path
[
draw,thick,blue,<
-
>
]
([
xshift
=-
2
em
]
rulepart
1
.south east
)
.. controls
+(
south:
1
.
7
)
and
+(
north:
1
.
3
)
..
([
xshift
=
0
em,yshift
=
0
.
10
em
]
cw
1
.north
)
node
[
pos
=
0
.
5
, below,xshift
=
0
.
3
in
]
{
\scriptsize
{
树片段的匹配
}}
;
}
\end
{
scope
}
\end
{
tikzpicture
}
\end
{
center
}
\end
{
frame
}
%%%------------------------------------------------------------------------------------------------------------
%%% 基于串的解码
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论