Nomio4640 commited on
Commit
8d189d1
·
1 Parent(s): 1ab3f6a
Files changed (1) hide show
  1. nlp_core/topic_modeler.py +9 -3
nlp_core/topic_modeler.py CHANGED
@@ -257,9 +257,15 @@ class TopicModeler:
257
  # Map from valid_texts index back to original texts index
258
  result_map: Dict[int, TopicResult] = {}
259
  for pos, (orig_idx, topic_id) in enumerate(zip(indices, topics)):
260
- prob = probs[pos] if probs is not None and hasattr(probs[pos], '__float__') else 0.0
261
- topic_words = model.get_topic(topic_id)
262
- keywords = [w for w, _ in (topic_words or [])[:5]]
 
 
 
 
 
 
263
 
264
  topic_row = topic_info[topic_info["Topic"] == topic_id]
265
  if not topic_row.empty and "Name" in topic_row.columns:
 
257
  # Map from valid_texts index back to original texts index
258
  result_map: Dict[int, TopicResult] = {}
259
  for pos, (orig_idx, topic_id) in enumerate(zip(indices, topics)):
260
+ try:
261
+ prob = float(probs[pos]) if probs is not None else 0.0
262
+ except (TypeError, IndexError, ValueError):
263
+ prob = 0.0
264
+ try:
265
+ topic_words = model.get_topic(topic_id)
266
+ keywords = [w for w, _ in (topic_words or [])[:5]]
267
+ except Exception:
268
+ keywords = []
269
 
270
  topic_row = topic_info[topic_info["Topic"] == topic_id]
271
  if not topic_row.empty and "Name" in topic_row.columns: