Commit c36bc0ad by xiaotong

tree matching

parent af19426a
...@@ -4609,6 +4609,205 @@ NP-BAR(NN$_1$ NP-BAR$_2$) $\to$ NN$_1$ NP-BAR$_2$ ...@@ -4609,6 +4609,205 @@ NP-BAR(NN$_1$ NP-BAR$_2$) $\to$ NN$_1$ NP-BAR$_2$
\end{frame} \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.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{源语言句子}}};
\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{-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[rectangle,draw,inner sep=2pt] [fit = (rulepart1) (rulepart2)] (rulemark) {};
}
\end{pgfonlayer}
\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->{
\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) {};
}
\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}
\end{frame}
%%%------------------------------------------------------------------------------------------------------------ %%%------------------------------------------------------------------------------------------------------------
%%% 基于串的解码 %%% 基于串的解码
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论