We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents bf41c46 + d218600 commit 2936b8bCopy full SHA for 2936b8b
src/TokenPassing.py
@@ -52,9 +52,9 @@ def log(val):
52
return float('-inf')
53
54
55
-def ctcTokenPassing(mat, classes, charWords):
+def ctcTokenPassing(mat, classes, charWords, blankIdx=None):
56
"implements CTC Token Passing Algorithm as shown by Graves (Dissertation, p67-69)"
57
- blankIdx = len(classes)
+ blankIdx = len(classes) if blankIdx is None else blankIdx
58
maxT, _ = mat.shape
59
60
# special s index for beginning and end of word
@@ -107,7 +107,11 @@ def ctcTokenPassing(mat, classes, charWords):
107
# 18-24
108
s = 1
109
while s <= len(wPrime):
110
- P = [toks.get(wIdx, s, t-1), toks.get(wIdx, s - 1, t - 1)]
+ if s == 1:
111
+ P = [toks.get(wIdx, s, t - 1), toks.get(wIdx, s - 1, t)]
112
+ else:
113
+ P = [toks.get(wIdx, s, t - 1), toks.get(wIdx, s - 1, t - 1)]
114
+
115
if wPrime[s-1] != blankIdx and s > 2 and wPrime[s - 2 - 1] != wPrime[s - 1]:
116
tok = toks.get(wIdx, s - 2, t - 1)
117
P.append(Token(tok.score, tok.history))
0 commit comments