Created
June 2, 2013 07:14
-
-
Save thuvh/5692891 to your computer and use it in GitHub Desktop.
decode processing in machine translation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{tikz} | |
\usetikzlibrary{shapes,arrows} | |
\usepackage{amsmath,bm,times} | |
\newcommand{\mx}[1]{\mathbf{\bm{#1}}} % Matrix command | |
\newcommand{\vc}[1]{\mathbf{\bm{#1}}} % Vector command | |
\usetikzlibrary{external} | |
%%%%%%%%%%% latex | |
%\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error | |
%-interaction=batchmode -jobname "\image" "\texsource" && | |
%dvips -o "\image".ps "\image".dvi && | |
%ps2eps "\image.ps"}} | |
%%%%%%%%%%% pdflatex | |
\tikzset{external/system call={pdflatex \tikzexternalcheckshellescape -halt-on-error | |
-interaction=batchmode -jobname "\image" "\texsource" && % or ; | |
pdftops -eps "\image".pdf}} | |
\tikzexternalize[shell escape=-enable-write18] | |
%pdflatex \tikzexternalcheckshellescape -halt-on-error | |
%-interaction=batchmode -jobname "\image" "\texsource" && % or ; | |
%pdftops -eps "\image".pdf | |
\begin{document} | |
\pagestyle{empty} | |
% We need layers to draw the block diagram | |
\pgfdeclarelayer{background} | |
\pgfdeclarelayer{foreground} | |
\pgfsetlayers{background,main,foreground} | |
% Define a few styles and constants | |
\tikzstyle{sensor}=[text width=14em, text centered, minimum height=2.5em] | |
\tikzstyle{ann} = [above, text width=5em] | |
\tikzstyle{naveqs} = [sensor, draw, text width=15em, minimum height=14em, rounded corners, text centered] | |
\tikzstyle{block} = [rectangle, draw, text centered] | |
\tikzstyle{line} = [draw, -latex'] | |
%fill=red!20, | |
\def\blockdist{4.0} | |
\def\edgedist{2.5} | |
\begin{tikzpicture} | |
\node (f) [block] {Souce Language Sentence}; | |
\node (chunk) [block, below of=f, node distance=1cm]{Building Shallow Syntactic}; | |
\node (rule) [block, below of=chunk, node distance=1cm]{Applying Transformation Rules}; | |
\node (model) [naveqs, below of=rule, node distance=3.2cm] {% | |
\begin{minipage}{0.5\textwidth} | |
Beam Search | |
\begin{align*} | |
e^{*} =\operatorname*{arg\,max}_e \sum_{m=0}^{M} \lambda_{m}h_{m}(e, f) | |
\end{align*} | |
Decoding | |
\end{minipage}}; | |
\node (e) [block, below of=model, node distance=3.2cm] {Target Language Sentence}; | |
% Note the use of \path instead of \node at ... below. | |
\path [line] (f) -- (chunk); | |
\path [line] (chunk) -- (rule); | |
\path [line] (rule) -- (model); | |
\path [line] (model) -- (e); | |
\path (model.35)+(\blockdist, 0) node (lm) [sensor] {Language Model ($h_1(e)$)}; | |
\path (model.15)+(\blockdist,0) node (tm) [sensor] {Translation Model ($h_2(e,f)$)}; | |
\path (model.-10)+(\blockdist,0) node (o) [sensor] {$\vdots$}; | |
% Unfortunately we cant use the convenient \path (fromnode) -- (tonode) | |
% syntax here. This is because TikZ draws the path from the node centers | |
% and clip the path at the node boundaries. We want horizontal lines, but | |
% the sensor and naveq blocks aren't aligned horizontally. Instead we use | |
% the line intersection syntax |- to calculate the correct coordinate | |
% \path [line] (lm) -- (model); | |
\path [draw, ->] (lm) -- (model.east |- lm); | |
\path [draw, ->] (tm) -- (model.east |- tm); | |
% % We could simply have written (gyros) .. (naveq.140). However, it's | |
% % best to avoid hard coding coordinates | |
% \path [draw, ->] (accel) -- node [above] {$\vc{f}^b$} | |
% (naveq.west |- accel); | |
% | |
% \node (IMU) [below of=accel] {IMU}; | |
% \path (naveq.south west)+(-0.6,-0.4) node (INS) {INS}; | |
% \draw [->] (naveq.50) -- node [ann] {Velocity } + (\edgedist,0) | |
% node[right] {$\vc{v}^l$}; | |
% \draw [->] (naveq.20) -- node [ann] {Attitude} + (\edgedist,0) | |
% node[right] { $\mx{R}_l^b$}; | |
% \draw [->] (naveq.-25) -- node [ann] {Horisontal position} + (\edgedist,0) | |
% node [right] {$\mx{R}_e^l$}; | |
% \draw [->] (naveq.-50) -- node [ann] {Depth} + (\edgedist,0) | |
% node[right] {$z$}; | |
% Now it's time to draw the colored IMU and INS rectangles. | |
% To draw them behind the blocks we use pgf layers. This way we | |
% can use the above block coordinates to place the backgrounds | |
\begin{pgfonlayer}{background} | |
% % Compute a few helper coordinates | |
% \path (lm.west |- model.north)+(-0.5,0.3) node (a) {}; | |
% \path (INS.south -| naveq.east)+(+0.3,-0.2) node (b) {}; | |
% \path[fill=yellow!20,rounded corners, draw=black!50, dashed] | |
% (a) rectangle (b); | |
\path (lm.north west)+(-0.2,0.2) node (a) {}; | |
\path (o.south -| lm.east)+(+0.2,-0.2) node (b) {}; | |
\path[draw=black!50, dashed] (a) rectangle (b); | |
\end{pgfonlayer} | |
\end{tikzpicture} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment