wilmerags commited on
Commit
dded833
·
1 Parent(s): ec9c642

feat: Adding try catch for not enough words topics

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -166,7 +166,10 @@ def generate_plot(
166
  cluster_to_words_similarities = sorted(cluster_to_words_similarities, key=lambda x: x[1], reverse=True)
167
  st.write(cluster_to_words_similarities)
168
  while len(cluster_keyword[label]) < 3:
169
- most_descriptive = cluster_to_words_similarities.pop(0)
 
 
 
170
  cluster_keyword[label].append(cluster_words[most_descriptive[0]])
171
  cluster_keyword[label] = ', '.join(cluster_keyword[label])
172
  encoded_labels_keywords = [cluster_keyword[encoded_label] for encoded_label in encoded_labels]
 
166
  cluster_to_words_similarities = sorted(cluster_to_words_similarities, key=lambda x: x[1], reverse=True)
167
  st.write(cluster_to_words_similarities)
168
  while len(cluster_keyword[label]) < 3:
169
+ try:
170
+ most_descriptive = cluster_to_words_similarities.pop(0)
171
+ except IndexError:
172
+ continue
173
  cluster_keyword[label].append(cluster_words[most_descriptive[0]])
174
  cluster_keyword[label] = ', '.join(cluster_keyword[label])
175
  encoded_labels_keywords = [cluster_keyword[encoded_label] for encoded_label in encoded_labels]