Skip to content
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

Gensim 3.1.0 Phrase loader incompatible with older models due to introduction of common_terms #1751

Closed
dldx opened this issue Dec 2, 2017 · 8 comments · Fixed by #1758
Closed
Labels
bug Issue described a bug

Comments

@dldx
Copy link

dldx commented Dec 2, 2017

I have a Phrases model that was computed using Gensim 2.2.0 but because of changes in 3.1.0 (I believe), I cannot load it anymore. This is the error I get:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<timed exec> in <module>()

~/Stuff/Sources/anaconda3/envs/nlp/lib/python3.6/site-packages/gensim/models/phrases.py in __init__(self, phrases_model)
    546         self.delimiter = phrases_model.delimiter
    547         self.scoring = phrases_model.scoring
--> 548         self.common_terms = phrases_model.common_terms
    549         corpus = self.pseudocorpus(phrases_model)
    550         self.phrasegrams = {}

AttributeError: 'Phrases' object has no attribute 'common_terms'

Cheers!

@piskvorky piskvorky added the bug Issue described a bug label Dec 3, 2017
@menshikh-iv
Copy link
Contributor

menshikh-iv commented Dec 4, 2017

Thanks for the report @dldx .

Ping @alexgarel, can you fix the load method in phrases to handle older models?

@alexgarel
Copy link
Contributor

hi @menshikh-iv, I can do it. But should I base on master or develop ?

@menshikh-iv
Copy link
Contributor

@alexgarel develop please :)

menshikh-iv pushed a commit that referenced this issue Dec 6, 2017
* backward compatibility for Phrases models without common_terms

* Phraser also needs compatible load for versions without scoring or common_terms

* minor: simplify persitence tests in test_phrases by using a context manager for temporary file management

* using six for python compatibility in phrases

* better tests for phrases load backward compatibility (this also fix a bug in loading  phrases model before scoring). Also moving temporary_file context manager in gensim.test.utils

* pep8 fix

* fix imports, reuse datapath

* remove unused import
@dldx
Copy link
Author

dldx commented Dec 7, 2017

Thanks for the quick fix!

@Raghuvar
Copy link

Raghuvar commented Mar 8, 2018

Had the same issue. Helped me a bit, still heading around.

@menshikh-iv
Copy link
Contributor

@Raghuvar please update your gensim version to latest

@Raghuvar
Copy link

@menshikh-iv Done it and got rid of the issues. Now it's working great.
Anyway, Thanks @menshikh-iv

@menshikh-iv
Copy link
Contributor

@Raghuvar say thanks to @alexgarel (it's a fix from him) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue described a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants