Commit d0ba52a4 by 姜雨帆

update cyk

parent 98a66bb3
......@@ -3740,7 +3740,7 @@ d = r_1 \circ r_2 \circ r_3 \circ r_4
\end{tikzpicture}
\end{center}
\vspace{0.3em}
\item 由于对文法中的非终结符进行了限制,可以直接使用CYK算法进行解码,无需转换成乔姆斯基范式
%\item 由于对文法中的非终结符进行了限制,可以直接使用CYK算法进行解码,无需转换成乔姆斯基范式
\end{itemize}
\end{frame}
......@@ -3754,7 +3754,7 @@ d = r_1 \circ r_2 \circ r_3 \circ r_4
\item 输入:源语串\textbf{s =} $s_1 ... s_J$,以及上下文无关文法$G$
\item 输出:判断字符串是否符合上下文无关文法
\end{itemize}
%\vspace{-0.5em}
\vspace{-0.7em}
\begin{center}
\begin{tikzpicture}
\tikzstyle{alignmentnode} = [rectangle,fill=blue!30,minimum size=0.45em,text=white,inner sep=0.1pt]
......@@ -3762,17 +3762,17 @@ d = r_1 \circ r_2 \circ r_3 \circ r_4
\tikzstyle{srcnode} = [anchor=south west]
\begin{scope}[scale=0.85]
\node[srcnode] (c1) at (0,0) {\small{\textbf{Function} CKY-Algorithm($s,G$)}};
\node[srcnode,anchor=north west] (c21) at ([xshift=2em,yshift=0.4em]c1.south west) {\small{\textbf{foreach} ($j_1, j_2$): 1$ \leq j_1 \leq J$ and 1$ \leq j_2 \leq J$}};
\node[srcnode,anchor=north west] (c22) at ([xshift=2em,yshift=0.4em]c21.south west) {\small{Initialize $cell[j_1,j_2 ]$}};
\node[srcnode,anchor=north west] (c3) at ([xshift=-2em,yshift=0.4em]c22.south west) {\small{\textbf{for} $j_1$ = 1 to $J$}};
\node[srcnode,anchor=west] (c31) at ([xshift=5em]c3.east) {\small{// beginning of span}};
\node[srcnode,anchor=north west] (c4) at ([xshift=2em,yshift=0.4em]c3.south west) {\small{\textbf{for} $j_2$ = $j_1$ to $J$}};
\node[srcnode,anchor=north west] (c41) at ([yshift=0.4em]c31.south west) {\small{// ending of span}};
\node[srcnode,anchor=north west] (c5) at ([xshift=2em,yshift=0.4em]c4.south west) {\small{\textbf{for} $k$ = $j_1$ to $j_2$}};
\node[srcnode,anchor=north west] (c21) at ([xshift=1.5em,yshift=0.4em]c1.south west) {\small{\textbf{foreach} ($j_1, j_2$): 0$ \leq j_1,j_2 \leq J$ and $ j_1 \textless j_2$}};
\node[srcnode,anchor=north west] (c22) at ([xshift=1.5em,yshift=0.4em]c21.south west) {\small{$span[j_1,j_2 ]$.updatePhrase($G$)}};
\node[srcnode,anchor=north west] (c3) at ([xshift=-1.5em,yshift=0.4em]c22.south west) {\small{\textbf{for} $l_{span}$ = 1 to $J$}};
\node[srcnode,anchor=west] (c31) at ([xshift=6em]c3.east) {\small{// length of span}};
\node[srcnode,anchor=north west] (c4) at ([xshift=1.5em,yshift=0.4em]c3.south west) {\small{\textbf{for} $j$ = 0 to $J-l_{span}$}};
\node[srcnode,anchor=north west] (c41) at ([yshift=0.4em]c31.south west) {\small{// begining of span}};
\node[srcnode,anchor=north west] (c5) at ([xshift=1.5em,yshift=0.4em]c4.south west) {\small{\textbf{for} $k$ = $j$ to $j+l_{span}$}};
\node[srcnode,anchor=north west] (c51) at ([yshift=0.4em]c41.south west) {\small{// partition of span}};
\node[srcnode,anchor=north west] (c6) at ([xshift=2em,yshift=0.4em]c5.south west) {\small{$hypos$ = Compose($cell[j_1, k], cell[k, j_2]$)}};
\node[srcnode,anchor=north west] (c7) at ([yshift=0.4em]c6.south west) {\small{$cell[j_1, j_2]$.update($hypos$)}};
\node[srcnode,anchor=north west] (c8) at ([xshift=-6em,yshift=0.4em]c7.south west) {\small{\textbf{return} $cell[1, J]$}};
\node[srcnode,anchor=north west] (c6) at ([xshift=1.5em,yshift=0.4em]c5.south west) {\small{$hypos$ = Compose($span[j, k], span[k, j+l_{span}]$)}};
\node[srcnode,anchor=north west] (c7) at ([yshift=0.4em]c6.south west) {\small{$span[j, j+l_{span}]$.update($hypos$)}};
\node[srcnode,anchor=north west] (c8) at ([xshift=-4.5em,yshift=0.4em]c7.south west) {\small{\textbf{return} $span[0, J]$}};
\node[srcnode] (s1) at ([yshift=-2.5em]c8.south west) {\textbf{s:}};
......@@ -3784,8 +3784,8 @@ d = r_1 \circ r_2 \circ r_3 \circ r_4
\node[srcnode] (s7) at ([xshift=1em]s6.south east) {$s_6$};
\node[srcnode] (s8) at ([xshift=1em]s7.south east) {$s_7$};
\node[srcnode,anchor=center] (j1) at ([yshift=-1.4em]s3.south) {$j_1$};
\node[srcnode,anchor=center] (j2) at ([yshift=-1.4em]s7.south) {$j_2$};
\node[srcnode,anchor=center] (j1) at ([yshift=-1.4em]s3.south) {$j$};
\node[srcnode,anchor=center] (j2) at ([yshift=-1.4em]s7.south) {$j+l_{span}$};
\node[srcnode,anchor=center] (k) at ([xshift=1.5em,yshift=-1.5em]s4.south) {$k$};
......@@ -3949,10 +3949,10 @@ d = r_1 \circ r_2 \circ r_3 \circ r_4
\begin{frame}{CYK解码(续)}
% 看NiuTrans Manual
\begin{itemize}
\item CYK解码提出了一种cell的数据结构,用来记录所有可能出现的翻译假设。
\item 实际上,在层次短语解码的时候,不能直接使用CYK算法,需要先转化为乔姆斯基范式,才能进行解码
\begin{itemize}
\item<2-> 对于每个源语句子,使用短语规则表初始化它的cell
\item<3-> 自底向上对cell中的每个子cell进行重新组合(正向、反向)
\item<2-> 对于每个源语句子,使用短语规则表初始化它的span
\item<3-> 自底向上对span中的每个子span进行重新组合(正、反向)
\item<4-> 计算每个推导的得分并记录下来,最终选择最优推导所对应的译文作为输出
\end{itemize}
\end{itemize}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论