-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
catch loading older TfidfModels without smartirs #2559
Conversation
Thanks! CC @Witiko can you review please? |
@piskvorky Sorry for the late response, I was on a vacation. The pull request LGTM. |
Perhaps we could add a unit test that tests the loading of a pre-3.8.0 |
@Witiko Sure. I can add a unit test. I'd like to confirm the correct way: I'd make a model with 3.7 save as a binary in gensim/test/test_data and write the test of loading that model. Correct? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but we need tests to cover the new functionality (e.g. loading an old model without smartirs and showing that it still works correctly).
@bnomis There already exist such models (for example |
@Witiko I've updated my pull request to include a test for backward compatibility. The tfidf_model.tst test model has the smartirs attribute. So does not show the issue. Therefore, I added a test tfidf model made with version 3.2.0 to have a file to load and test against. |
Looks ok. The test on lines 444–447 can be simplified to |
@Witiko Updated |
Looks good to me. |
Older pre-3.8.0 TfidfModels do not have the smartirs attribute. But the 3.8.0 code assumes the smartirs attribute exists. For exampe in getitem(). This causes a crash when using loaded models that were saved with older versions of gensim. This PR adds code to the load() method to set smartirs to None if it is not set via the loaded model.