boudinfl/pke

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

artdream-dubai opened this issue · 3 comments

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 commented

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

ygorg commented

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.