partial heavy refactoring of the word embedding package