andrewtavis / kwx

BERT, LDA, and TFIDF based keyword extraction in Python
BSD 3-Clause "New" or "Revised" License
70 stars 10 forks source link

Error "__init__() got an unexpected keyword argument 'common_terms'" occured when running example kw_extraction.ipynb #30

Closed Y-H-Lai closed 3 years ago

Y-H-Lai commented 3 years ago

Hi, I am trying to run notebook "kw_extraction.ipynb" given as example in Google Colab. When I am at the step of preparing data, I got error "init() got an unexpected keyword argument 'common_terms'".

image

May I know how to solve this? It seems like it is using a parameter that does not exist in gensim_models.phrases anymore, so shall I change the version of gensim to a lower level...?

andrewtavis commented 3 years ago

Hi and thanks for reporting :) I just did an update to pyLDAvis for this that might be causing the new issues, and generally this is related to #21, as ideally kwx would be updated so that it can be used with gensim 4.x that works for all Python versions that this supports.

To start though, what's your gensim version?

andrewtavis commented 3 years ago

My local environment still has gensim==3.8.0, which is what's also in the requirements.txt and environment.yml, so the version shouldn't need to be lowered. common_terms is a gensim 3.x argument that's been switched to connector_words in gensim 4.x.

Y-H-Lai commented 3 years ago

I see, initially my gensim version in Google Colab is gensim-3.6.0, after running the command to upgrade it, it becomes gensim-4.0.1. So, both of them are not compatible lol I will look out for the coming update of kwx then. Thank you for the quick reply!

andrewtavis commented 3 years ago

Very welcome :) I'll try and figure out a way to support 3.8 and 4.X for gensim. Dependency issues are not my favorite 😄 It's good to know that it also doesn't work for 3.6 though, as that means that common_terms was added after that.

Thanks again for bringing this to my attention!

andrewtavis commented 3 years ago

@Y-H-Lai, I reopened this as I expect that others will potentially run into the same problem. #33 will update kwx so that the line in question for the data cleaning will check the gensim version and use connector_words for 4.x and common_terms for 3.x. It now all should work on 3.8.x and 4.x versions of gensim, but not for earlier versions where that argument is not available :)

Thanks again for bringing this up! Had honestly been avoiding #21 for a bit, but it wasn't so bad after all 😊