Skip to content

Instantly share code, notes, and snippets.

@sbos
Last active October 22, 2016 18:04
Show Gist options
  • Save sbos/5720d443c04f278316ba09cda5502739 to your computer and use it in GitHub Desktop.
Save sbos/5720d443c04f278316ba09cda5502739 to your computer and use it in GitHub Desktop.
function write_word2vec(path::AbstractString, vm::VectorModel, dict::Dictionary)
fout = open(path, "w")
sense_prob = zeros(T(vm))
write(fout, "$(V(vm)) $(T(vm)) $(M(vm))\n")
for v in 1:V(vm)
write(fout, "$(dict.id2word[v])\n")
expected_pi!(sense_prob, vm, v)
for k in 1:T(vm)
if sense_prob[k] < 1e-3 continue end
write(fout, "$k $(sense_prob[k]) ")
for i in 1:M(vm)
write(fout, vm.In[i, k, v])
end
write(fout, "\n")
end
end
close(fout)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment