Commit a46b425f by xiaotong

Merge branch 'master' of 47.105.50.196:NiuTrans/Toy-MT-Introduction

parents dc0c0cf3 cb60731b
......@@ -3819,140 +3819,134 @@ d = r_1 \circ r_2 \circ r_3 \circ r_4
% 看NiuTrans Manual
\begin{itemize}
\item 我们来看一个CYK算法的具体例子,给定一个上下无关文法以及一个单词\alert{aabbc},来判断该单词是否属于此文法,解析流程如下
\vspace{-0.5em}
\vspace{-0.3em}
\begin{center}
\begin{tikzpicture}
\tikzstyle{alignmentnode} = [rectangle,fill=blue!30,minimum size=0.45em,text=white,inner sep=0.1pt]
\tikzstyle{alignmentnode} = [rectangle,fill=blue!30,minimum size=0.5em,text=white,inner sep=0.1pt]
\tikzstyle{selectnode} = [rectangle,fill=green!20,minimum height=1.5em,minimum width=1.5em,inner sep=1.2pt]
\tikzstyle{srcnode} = [anchor=south west]
\tikzstyle{chartnode}=[rectangle,minimum size=1.3em,draw]
\begin{scope}[scale=0.85]
\node[srcnode] (c1) at (0,0) {\small{a}};
\node[srcnode] (c2) at ([xshift=1em]c1.south east) {\small{a}};
\node[srcnode] (c3) at ([xshift=1em]c2.south east) {\small{b}};
\node[srcnode] (c4) at ([xshift=1em]c3.south east) {\small{b}};
\node[srcnode] (c5) at ([xshift=1em]c4.south east) {\small{c}};
\node[anchor=south east] (g1) at ([xshift=1em,yshift=3.0em]c1.north west) {\small{$\textrm{S} \to \textrm{AB}\ \ \ \textrm{A} \to \textrm{CD}\ \vert \ \textrm{CF}\ \ \ \textrm{B} \to \textrm{c}\ \vert \ \textrm{BE}$}};
\node[anchor=north west] (g2) at ([yshift=0.1em]g1.south west) {\small{$\textrm{C} \to \textrm{a}\ \ \ \ \textrm{D} \to \textrm{b}\ \ \ \ \textrm{E} \to \textrm{c}\ \ \ \ \textrm{F} \to \textrm{AD}$}};
\node[anchor=south east] (g1) at (0,0) {\small{$\textrm{S} \to \textrm{AB}\ \ \ \textrm{A} \to \textrm{CD}\ \vert \ \textrm{CF}\ \ \ \textrm{B} \to \textrm{c}\ \vert \ \textrm{BE}$}};
\node[anchor=north west] (g2) at ([yshift=0.3em]g1.south west) {\small{$\textrm{C} \to \textrm{a}\ \ \ \ \textrm{D} \to \textrm{b}\ \ \ \ \textrm{E} \to \textrm{c}\ \ \ \ \textrm{F} \to \textrm{AD}$}};
\begin{pgfonlayer}{background}
\node [rectangle,inner sep=0.2em,rounded corners=1pt,fill=green!10,drop shadow,draw=ugreen] [fit = (g1) (g2)] (gl1) {};
\node [rectangle,inner sep=0.1em,rounded corners=1pt,fill=green!10,drop shadow,draw=ugreen] [fit = (g1) (g2)] (gl1) {};
\end{pgfonlayer}
\vspace{0.5em}
\node [anchor=center,alignmentnode] (alig11) at ([yshift=-2em]c1.south) {};
\node [anchor=center,alignmentnode] (alig21) at ([yshift=-2em]alig11.center) {};
\node [anchor=center,alignmentnode] (alig31) at ([yshift=-2em]alig21.center) {};
\node [anchor=center,alignmentnode] (alig41) at ([yshift=-2em]alig31.center) {};
\node [anchor=center,alignmentnode] (alig51) at ([yshift=-2em]alig41.center) {};
\node [anchor=center,alignmentnode] (alig12) at ([yshift=-2em]c2.south) {};
\node [anchor=center,alignmentnode] (alig22) at ([yshift=-2em]alig12.center) {};
\node [anchor=center,alignmentnode] (alig32) at ([yshift=-2em]alig22.center) {};
\node [anchor=center,alignmentnode] (alig42) at ([yshift=-2em]alig32.center) {};
\node [anchor=center,alignmentnode] (alig13) at ([yshift=-2em]c3.south) {};
\node [anchor=center,alignmentnode] (alig23) at ([yshift=-2em]alig13.center) {};
\node [anchor=center,alignmentnode] (alig33) at ([yshift=-2em]alig23.center) {};
\node [anchor=center,alignmentnode] (alig14) at ([yshift=-2em]c4.south) {};
\node [anchor=center,alignmentnode] (alig24) at ([yshift=-2em]alig14.center) {};
\node [anchor=center,alignmentnode] (alig15) at ([yshift=-2em]c5.south) {};
\node [anchor=center] (x1) at ([yshift=1.2em]alig11.center) {\tiny{1}};
\node [anchor=center] (x1) at ([yshift=1.2em]alig12.center) {\tiny{2}};
\node [anchor=center] (x1) at ([yshift=1.2em]alig13.center) {\tiny{3}};
\node [anchor=center] (x1) at ([yshift=1.2em]alig14.center) {\tiny{4}};
\node [anchor=center] (x1) at ([yshift=1.2em]alig15.center) {\tiny{5}};
\node [anchor=center] (y1) at ([xshift=-1.2em]alig11.center) {\tiny{1}};
\node [anchor=center] (y1) at ([xshift=-1.2em]alig21.center) {\tiny{2}};
\node [anchor=center] (y1) at ([xshift=-1.2em]alig31.center) {\tiny{3}};
\node [anchor=center] (y1) at ([xshift=-1.2em]alig41.center) {\tiny{4}};
\node [anchor=center] (y1) at ([xshift=-1.2em]alig51.center) {\tiny{5}};
\node[anchor=west] (l1) at ([xshift=-19.2em,yshift=2em]alig11.west) {\small{1.首先建立一个5*5的上三角矩阵}};
\node[anchor=west] (l2) at ([xshift=0.8em,yshift=-1.5em]l1.west) {\small{cell[i][j]代表范围内所有语法成分}};
\node [anchor=east] (s1) at ([xshift=-3em,yshift=-3em]g2.west) {a};
\node [anchor=north west] (s2) at ([yshift=-1em]s1.south west) {a};
\node [anchor=north west] (s3) at ([yshift=-1em]s2.south west) {b};
\node [anchor=north west] (s4) at ([yshift=-1em]s3.south west) {b};
\node [anchor=north west] (s5) at ([yshift=-1em]s4.south west) {c};
\node [alignmentnode,anchor=west] (cell11) at ([xshift=1em]s1.east) {};
\node [alignmentnode,anchor=west] (cell21) at ([xshift=1em]s2.east) {};
\node [alignmentnode,anchor=west] (cell22) at ([xshift=2em]cell21.east) {};
\node [alignmentnode,anchor=west] (cell31) at ([xshift=1em]s3.east) {};
\node [alignmentnode,anchor=west] (cell32) at ([xshift=2em]cell31.east) {};
\node [alignmentnode,anchor=west] (cell33) at ([xshift=2em]cell32.east) {};
\node [alignmentnode,anchor=west] (cell41) at ([xshift=1em]s4.east) {};
\node [alignmentnode,anchor=west] (cell42) at ([xshift=2em]cell41.east) {};
\node [alignmentnode,anchor=west] (cell43) at ([xshift=2em]cell42.east) {};
\node [alignmentnode,anchor=west] (cell44) at ([xshift=2em]cell43.east) {};
\node [alignmentnode,anchor=west] (cell51) at ([xshift=1em]s5.east) {};
\node [alignmentnode,anchor=west] (cell52) at ([xshift=2em]cell51.east) {};
\node [alignmentnode,anchor=west] (cell53) at ([xshift=2em]cell52.east) {};
\node [alignmentnode,anchor=west] (cell54) at ([xshift=2em]cell53.east) {};
\node [alignmentnode,anchor=west] (cell55) at ([xshift=2em]cell54.east) {};
\node [anchor=north] (l1) at ([yshift=-0.5em]cell51.south) {\scriptsize{$l$=1}};
\node [anchor=north] (l2) at ([yshift=-0.5em]cell52.south) {\scriptsize{$l$=2}};
\node [anchor=north] (l3) at ([yshift=-0.5em]cell53.south) {\scriptsize{$l$=3}};
\node [anchor=north] (l4) at ([yshift=-0.5em]cell54.south) {\scriptsize{$l$=4}};
\node [anchor=north] (l5) at ([yshift=-0.5em]cell55.south) {\scriptsize{$l$=5}};
\node [anchor=center] (y1) at ([xshift=-1.2em,yshift=1.3em]cell11.center) {\scriptsize{\blue 0}};
\node [anchor=center] (y2) at ([xshift=-1.2em,yshift=1.3em]cell21.center) {\scriptsize{\blue 1}};
\node [anchor=center] (y3) at ([xshift=-1.2em,yshift=1.3em]cell31.center) {\scriptsize{\blue 2}};
\node [anchor=center] (y4) at ([xshift=-1.2em,yshift=1.3em]cell41.center) {\scriptsize{\blue 3}};
\node [anchor=center] (y5) at ([xshift=-1.2em,yshift=1.3em]cell51.center) {\scriptsize{\blue 4}};
\node [anchor=center] (y6) at ([xshift=-1.2em,yshift=-1em]cell51.center) {\scriptsize{\blue 5}};
\node [anchor=west] (num) at ([xshift=15em,yshift=0.5em]s1.east) {\footnotesize{序号}};
\node [anchor=west] (kua) at ([xshift=1em]num.east) {\footnotesize{跨度}};
\node [anchor=west] (tui) at ([xshift=1em]kua.east) {\footnotesize{推导}};
\draw[-] ([yshift=-0.1em]num.south west)--([xshift=13em,yshift=-0.1em]num.south west);
\visible<2->{
\node[anchor=west] (l3) at ([yshift=-4em]l1.west) {\small{2.从叶子到根找到所有可能的推导}};
\node[anchor=west] (l4) at ([xshift=0.8em,yshift=-1.5em]l3.west) {\small{如cell[1][3] = cell[1][1] + cell[2][3]}};
\node[anchor=west] (l5) at ([xshift=5.45em,yshift=-1.5em]l4.west) {\small{或cell[1][2] + cell[3][3]}};
}
\visible<10->{
\node[anchor=west] (l6) at ([yshift=-5em]l3.west) {\small{3.如果最后一个cell包含了起始符}};
\node[anchor=west] (l7) at ([xshift=0.8em,yshift=-1.5em]l6.west) {\small{则该单词可以由文法推导得到}};
}
\visible<2>{
\node [anchor=center,selectnode,fill=black!10] (alig11) at (alig11.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=red!30] (c1) at (c1.center) {\small{a}};
\node [anchor=west] (n1) at ([yshift=-1em]num.south west) {\footnotesize{1}};
\node [anchor=west] (k1) at ([yshift=-1em]kua.south west) {\footnotesize{[{\blue 0},{\blue 1}]}};
\node [anchor=west] (t1) at ([yshift=-1em]tui.south west) {\footnotesize{C $\to$ a}};
\node [anchor=center,selectnode,fill=black!10] (alig11) at (cell11.center) {\footnotesize{C}};
}
\visible<3->{
\node [anchor=center,selectnode,fill=blue!30] (alig11) at (alig11.center) {\footnotesize{C}};
}
\visible<3>{
\node [anchor=center,selectnode,fill=black!10] (alig12) at (alig12.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=red!30] (c2) at (c2.center) {\small{a}};
\node [anchor=center] (n2) at ([yshift=-1.3em]n1.center) {\footnotesize{2}};
\node [anchor=center] (k2) at ([yshift=-1.3em]k1.center) {\footnotesize{[{\blue 1},{\blue 2}]}};
\node [anchor=west] (t2) at ([yshift=-1.3em]t1.west) {\footnotesize{C $\to$ a}};
\node [anchor=center,selectnode,fill=black!10] (alig21) at (cell21.center) {\footnotesize{C}};
}
\visible<4->{
\node [anchor=center,selectnode,fill=blue!30] (alig12) at (alig12.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=blue!30] (alig13) at (alig13.center) {\footnotesize{D}};
\node [anchor=center,selectnode,fill=blue!30] (alig14) at (alig14.center) {\footnotesize{D}};
\node [anchor=center,selectnode,fill=blue!30] (alig15) at (alig15.center) {\footnotesize{B,E}};
\node [anchor=center] (n3) at ([yshift=-1.3em]n2.center) {\footnotesize{3}};
\node [anchor=center] (k3) at ([yshift=-1.3em]k2.center) {\footnotesize{[{\blue 2},{\blue 3}]}};
\node [anchor=west] (t3) at ([yshift=-1.3em]t2.west) {\footnotesize{D $\to$ b}};
\node [anchor=center,selectnode,fill=black!10] (alig31) at (cell31.center) {\footnotesize{D}};
}
\visible<5>{
\node [anchor=center,selectnode,fill=red!30] (alig11) at (alig11.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=red!30] (alig12) at (alig12.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=black!10] (alig21) at (alig21.center) {\footnotesize{}};
\visible<5->{
\node [anchor=center] (n4) at ([yshift=-1.3em]n3.center) {\footnotesize{4}};
\node [anchor=center] (k4) at ([yshift=-1.3em]k3.center) {\footnotesize{[{\blue 3},{\blue 4}]}};
\node [anchor=west] (t4) at ([yshift=-1.3em]t3.west) {\footnotesize{D $\to$ b}};
\node [anchor=center,selectnode,fill=black!10] (alig41) at (cell41.center) {\footnotesize{D}};
}
\visible<6->{
\node [anchor=center,selectnode,fill=blue!30] (alig21) at (alig21.center) {\footnotesize{}};
}
\visible<6>{
\node [anchor=center,selectnode,fill=red!30] (alig13) at (alig13.center) {\footnotesize{D}};
\node [anchor=center,selectnode,fill=red!30] (alig12) at (alig12.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=black!10] (alig22) at (alig22.center) {\footnotesize{A}};
\node [anchor=center] (n5) at ([yshift=-1.3em]n4.center) {\footnotesize{5}};
\node [anchor=center] (k5) at ([yshift=-1.3em]k4.center) {\footnotesize{[{\blue 4},{\blue 5}]}};
\node [anchor=west] (t5) at ([yshift=-1.3em]t4.west) {\footnotesize{B $\to$ c , E $\to$ c}};
\node [anchor=center,selectnode,fill=black!10] (alig51) at (cell51.center) {\footnotesize{B,E}};
}
\visible<7->{
\node [anchor=center,selectnode,fill=blue!30] (alig22) at (alig22.center) {\footnotesize{A}};
\node [anchor=center,selectnode,fill=blue!30] (alig23) at (alig23.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=blue!30] (alig24) at (alig24.center) {\footnotesize{}};
\node [anchor=center] (n6) at ([yshift=-1.3em]n5.center) {\footnotesize{6}};
\node [anchor=center] (k6) at ([yshift=-1.3em]k5.center) {\footnotesize{[{\blue 0},{\blue 2}]}};
\node [anchor=west] (t6) at ([yshift=-1.3em]t5.west) {\footnotesize{none}};
\node [anchor=center,selectnode,fill=black!10] (alig22) at (cell22.center) {\footnotesize{}};
}
\visible<8>{
\node [anchor=center,selectnode,fill=red!30] (alig11) at (alig11.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=red!30] (alig22) at (alig22.center) {\footnotesize{A}};
\node [anchor=center,selectnode,fill=black!10] (alig31) at (alig31.center) {\footnotesize{}};
\visible<8->{
\node [anchor=center] (n7) at ([yshift=-1.3em]n6.center) {\footnotesize{7}};
\node [anchor=center] (k7) at ([yshift=-1.3em]k6.center) {\footnotesize{[{\blue 1},{\blue 3}]}};
\node [anchor=west] (t7) at ([yshift=-1.3em]t6.west) {\footnotesize{A $\to$ CD}};
\node [anchor=center,selectnode,fill=black!10] (alig32) at (cell32.center) {\footnotesize{A}};
}
\visible<9>{
\node [anchor=center,selectnode,fill=red!30] (alig21) at (alig21.center) {\footnotesize{C}};
\node [anchor=center,selectnode,fill=red!30] (alig13) at (alig13.center) {\footnotesize{D}};
\node [anchor=center,selectnode,fill=black!10] (alig31) at (alig31.center) {\footnotesize{}};
}
\visible<10->{
\node [anchor=center,selectnode,fill=blue!30] (alig31) at (alig31.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=blue!30] (alig32) at (alig32.center) {\footnotesize{F}};
\node [anchor=center,selectnode,fill=blue!30] (alig33) at (alig33.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=blue!30] (alig41) at (alig41.center) {\footnotesize{A}};
\node [anchor=center,selectnode,fill=blue!30] (alig42) at (alig42.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=blue!30] (alig51) at (alig51.center) {\footnotesize{S}};
\visible<9->{
\node [anchor=center] (sep1) at ([yshift=-0.8em]n7.center) {\footnotesize{...}};
\node [anchor=center] (n8) at ([yshift=-1.8em]n7.center) {\footnotesize{15}};
\node [anchor=center] (k8) at ([yshift=-1.8em]k7.center) {\footnotesize{[{\blue 0},{\blue 5}]}};
\node [anchor=west] (t8) at ([yshift=-1.8em]t7.west) {\footnotesize{S $\to$ AB}};
\node [anchor=center,selectnode,fill=black!10] (alig33) at (cell33.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=black!10] (alig42) at (cell42.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=black!10] (alig43) at (cell43.center) {\footnotesize{F}};
\node [anchor=center,selectnode,fill=black!10] (alig44) at (cell44.center) {\footnotesize{A}};
\node [anchor=center,selectnode,fill=black!10] (alig52) at (cell52.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=black!10] (alig53) at (cell53.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=black!10] (alig54) at (cell54.center) {\footnotesize{}};
\node [anchor=center,selectnode,fill=black!10] (alig55) at (cell55.center) {\footnotesize{S}};
}
\end{scope}
\end{tikzpicture}
\end{center}
\end{itemize}
\end{frame}
%%%------------------------------------------------------------------------------------------------------------
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论