Created
April 26, 2016 17:53
-
-
Save daskol/56f6dfa2e38c075d04ae863b2a859ef3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from operator import itemgetter | |
| from collections import OrderedDict | |
| def word2index(model): | |
| """Extract word2index mapping from Word2Vec model. | |
| """ | |
| word2index = OrderedDict((v, k) for k, v in sorted(model.index2word, key=itemgetter(1))) | |
| return word2index |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment