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

Error in TopicalPageRank: 'numpy.ndarray' object has no attribute 'index' #218

Closed
artdream-dubai opened this issue Jan 23, 2023 · 3 comments · Fixed by #226
Closed

Error in TopicalPageRank: 'numpy.ndarray' object has no attribute 'index' #218

artdream-dubai opened this issue Jan 23, 2023 · 3 comments · Fixed by #226

Comments

@artdream-dubai
Copy link

Good afternoon. I occurred with an error when working with TopicalPageRank in the step of candidates extraction. Here:

elif model.name in ["TopicalPageRank"]:
extractor.candidate_weighting(lda_model=lda_model)

I worked with this algorithm in December and it worked ok. But now it gives an error:


AttributeError Traceback (most recent call last)
in
102 extractor.candidate_weighting(df=df)
103 elif model.name in ["TopicalPageRank"]:
--> 104 extractor.candidate_weighting(lda_model=lda_model)
105 else:
106 extractor.candidate_weighting()

/usr/local/lib/python3.8/dist-packages/pke/unsupervised/graph_based/single_tpr.py in candidate_weighting(self, window, pos, lda_model, normalized)
168 for word in self.graph.nodes():
169 if word in dictionary:
--> 170 index = dictionary.index(word)
171 distribution_word_topic = [distributions[k][index] for k
172 in range(K)]

AttributeError: 'numpy.ndarray' object has no attribute 'index'

@ygorg
Copy link
Collaborator

ygorg commented Mar 14, 2023

Hi, thanks for your issue. In your code what is lda_model ? How do you obtain it ?
Could you please share your code ?

@artdream-dubai
Copy link
Author

I use code from here
https://github.com/boudinfl/pke/blob/master/examples/benchmarking-models.ipynb

  • I add it into Colab and start

@ygorg
Copy link
Collaborator

ygorg commented Apr 10, 2023

Thanks for the info, I found the bug: in 8f1d05d we changed from tf_vectorizer.get_feature_names() to tf_vectorizer.get_feature_names_out() but the return value changed from list to np.ndarray which was not taken into account. I'm on it.

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

Successfully merging a pull request may close this issue.

2 participants