Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132938 views
License: OTHER
1
\documentclass{article}
2
\usepackage[pdftex,active,tightpage]{preview}
3
\setlength\PreviewBorder{2mm}
4
5
\usepackage[utf8]{inputenc} % this is needed for umlauts
6
\usepackage[ngerman]{babel} % this is needed for umlauts
7
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
8
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
9
\usepackage{braket} % needed for \Set
10
\usepackage{algorithm,algpseudocode}
11
12
\begin{document}
13
\begin{preview}
14
\begin{algorithm}[H]
15
\begin{algorithmic}
16
\Function{WER}{Reference $r$, Hypophysis $h$}
17
\State int[$|r|+1$][$|h|+1$] $D$ \Comment{Initialisation}
18
\For{($i=0$; $\;i \leq |r|$; $\;i$++)}
19
\For{($j=0$; $\;j \leq |h|$; $\;j$++)}
20
\If{$i==0$}
21
\State $D[0][j] \gets j$
22
\ElsIf{$j==0$}
23
\State $D[i][0] \gets i$
24
\EndIf
25
\EndFor
26
\EndFor
27
28
\State
29
\For{($i=1$; $\;i \leq |r|$; $\;i$++)} \Comment{Calculation}
30
\For{($j=1$; $\;j \leq |h|$; $\;j$++)}
31
\If{$r[i-1] == h[j-1]$}
32
\State $D[i][j] \gets D[i-1][j-1]$
33
\Else
34
\State $sub \gets D[i-1][j-1] + 1$
35
\State $ins \gets D[i][j-1] + 1$
36
\State $del \gets D[i-1][j] + 1$
37
\State $D[i][j] \gets \min(sub, ins, del)$
38
\EndIf
39
\EndFor
40
\EndFor
41
42
\State
43
\State \Return $D[|r|][|h|]$
44
\EndFunction
45
\end{algorithmic}
46
\caption{Calculation of WER with Levenshtein distance}
47
\label{alg:seq1}
48
\end{algorithm}
49
\end{preview}
50
\end{document}
51
52