literal port of word2vec.c