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
8b250298
Commit
8b250298
authored
Mar 02, 2020
by
姜雨帆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cyk
parent
867f95dd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
64 行增加
和
0 行删除
+64
-0
Section04-Phrasal-and-Syntactic-Models/section04.tex
+64
-0
没有找到文件。
Section04-Phrasal-and-Syntactic-Models/section04.tex
查看文件 @
8b250298
...
...
@@ -3754,6 +3754,70 @@ d = r_1 \circ r_2 \circ r_3 \circ r_4
\begin{frame}
{
CYK算法
}
% 看NiuTrans Manual
\begin{itemize}
\item
CYK算法通过遍历不同
\alert
{
span
}
来判断字符串是否符合文法
\begin{itemize}
\item
输入:源语串
\textbf
{
s =
}
$
s
_
1
... s
_
J
$
,以及上下文无关文法
$
G
$
\item
输出:判断字符串是否符合上下文无关文法
\end{itemize}
%\vspace{-0.5em}
\begin{center}
\begin{tikzpicture}
\tikzstyle
{
alignmentnode
}
= [rectangle,fill=blue!30,minimum size=0.45em,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]
\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]
(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]
(s1) at ([yshift=-2.5em]c8.south west)
{
\textbf
{
s:
}}
;
\node
[srcnode]
(s2) at ([xshift=1em]s1.south east)
{$
s
_
1
$}
;
\node
[srcnode]
(s3) at ([xshift=1em]s2.south east)
{$
s
_
2
$}
;
\node
[srcnode]
(s4) at ([xshift=1em]s3.south east)
{$
s
_
3
$}
;
\node
[srcnode]
(s5) at ([xshift=1em]s4.south east)
{$
s
_
4
$}
;
\node
[srcnode]
(s6) at ([xshift=1em]s5.south east)
{$
s
_
5
$}
;
\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]
(k) at ([xshift=1.5em,yshift=-1.5em]s4.south)
{$
k
$}
;
\draw
[->,thick]
([yshift=-0.1em]j1.north)--([yshift=0.1em]s3.south);
\draw
[->,thick]
([yshift=-0.1em]j2.north)--([yshift=0.1em]s7.south);
\draw
[->,thick]
([yshift=-0.1em]k.north)--([xshift=1.5em,yshift=0.1em]s4.south);
\node
[rectangle,inner sep=0.3em,rounded corners=1pt,very thick,dotted,draw=ugreen] [fit = (s3) (s7)] (box1)
{}
;
\begin{pgfonlayer}
{
background
}
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=blue!10!white] [fit = (c1) (c21) (c3) (c6) (c7) (c8)] (gl1)
{}
;
\node
[rectangle,inner sep=0.3em,rounded corners=1pt,fill=green!10!white] [fit = (s3) (s4)] (box2)
{}
;
\node
[rectangle,inner sep=0.3em,rounded corners=1pt,fill=red!10!white] [fit = (s5) (s7)] (box3)
{}
;
\end{pgfonlayer}
\end{scope}
\end{tikzpicture}
\end{center}
\end{itemize}
\end{frame}
%%%------------------------------------------------------------------------------------------------------------
%%% CYK解码
\begin{frame}
{
CYK算法
}
% 看NiuTrans Manual
\begin{itemize}
\item
我们来看一个CYK算法的具体例子,给定一个上下无关文法以及一个单词
\alert
{
aabbc
}
,来判断该单词是否属于此文法,解析流程如下
\vspace
{
-0.5em
}
\begin{center}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论