[MRG] fix for loading old word2vec models #1179
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes loading Word2Vec models from previous versions.
While loading pre-keyedvector word2vec models, the attributes which belonged to the
Word2Vec
instance before the change and to theKeyedVector
instance after the change, need to be set manually after unpickling the model. These were not being set correctly for models which saved the numpy data in separate files from the model file.There was a unittest to verify this behaviour explicitly, but the existing model in the test data seems to contain a
KeyedVector
instance already.I've updated the test data with a model without a keyedvector instance, and the code for loading models to handle this behaviour correctly.
Fixes #1173 (tested by loading the model linked in the issue and performing a lookup for "bon")