Skip to content

Commit

Permalink
Fixed #1981 (#1996)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greenpp authored May 29, 2024
1 parent be9376c commit 72cc3e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bertopic/representation/_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def extract_topics(self,
updated_topics = {topic: [] for topic in topics.keys()}

for topic, candidate_keywords in candidate_topics.items():
word_indices = [words_lookup.get(keyword) for keyword in candidate_keywords if words_lookup.get(keyword)]
vals = topic_model.c_tf_idf_[:, np.array(word_indices)][topic + topic_model._outliers]
word_indices = np.sort([words_lookup.get(keyword) for keyword in candidate_keywords if words_lookup.get(keyword)])
vals = topic_model.c_tf_idf_[:, word_indices][topic + topic_model._outliers]
indices = np.argsort(np.array(vals.todense().reshape(1, -1))[0])[-self.top_n_words:][::-1]
vals = np.sort(np.array(vals.todense().reshape(1, -1))[0])[-self.top_n_words:][::-1]
topic_words = [(words[word_indices[index]], val) for index, val in zip(indices, vals)]
Expand Down

0 comments on commit 72cc3e0

Please sign in to comment.