Skip to content

Commit 7e2d20b

Browse files
committed
handling empty vectors
1 parent f3a04ac commit 7e2d20b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/microtc.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ function predict_corpus(tc::MicroTC, corpus;
118118
normalize=true)
119119

120120
V = vectorize_corpus(tc.textmodel, corpus; normalize, minbatch)
121+
122+
for v in V
123+
if length(v) == 0 # empty vector
124+
v[rand(1:vocsize(tc.textmodel))] = 1f0
125+
end
126+
end
121127
#don't know if liblinear prediction is multithreading
122128
n = length(V)
123129
# minbatch = getminbatch(minbatch, n)

0 commit comments

Comments
 (0)