AIEcosystem commited on
Commit
b432801
·
verified ·
1 Parent(s): 4dbacfd

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +5 -7
src/streamlit_app.py CHANGED
@@ -66,8 +66,10 @@ category_mapping = {
66
  "Temporal & Events": ["event", "date"],
67
  "Digital & Products": ["platform", "product", "media_type", "url"],
68
  }
 
 
69
  reverse_category_mapping = {label: category
70
- for category, label_list in category_mapping.items() for label in label in label_list}
71
 
72
 
73
  # --- Utility Functions for Analysis and Plotly ---
@@ -251,7 +253,7 @@ def generate_network_graph(df, raw_text):
251
  showlegend=False,
252
  marker=dict(
253
  size=unique_entities['frequency'] * 5 + 10,
254
- color=[entity_color_map.get(label, '#cccccc') for label in unique_entities['label']],
255
  line_width=1,
256
  line_color='black',
257
  opacity=0.9
@@ -269,7 +271,7 @@ def generate_network_graph(df, raw_text):
269
  legend_traces = []
270
  seen_labels = set()
271
  for index, row in unique_entities.iterrows():
272
- label = row['label']
273
  if label not in seen_labels:
274
  seen_labels.add(label)
275
  color = entity_color_map.get(label, '#cccccc')
@@ -830,7 +832,3 @@ if st.session_state.show_results:
830
  height=800,
831
  scrolling=True
832
  )
833
-
834
-
835
-
836
-
 
66
  "Temporal & Events": ["event", "date"],
67
  "Digital & Products": ["platform", "product", "media_type", "url"],
68
  }
69
+
70
+ # FIX: Corrected the dictionary comprehension to avoid redundant iteration variable (preventing UnboundLocalError)
71
  reverse_category_mapping = {label: category
72
+ for category, label_list in category_mapping.items() for label in label_list}
73
 
74
 
75
  # --- Utility Functions for Analysis and Plotly ---
 
253
  showlegend=False,
254
  marker=dict(
255
  size=unique_entities['frequency'] * 5 + 10,
256
+ color=[entity_color_map.get(label, '#cccccc') for label in unique_entities['label']], # 'label' is safe here (local to list comprehension)
257
  line_width=1,
258
  line_color='black',
259
  opacity=0.9
 
271
  legend_traces = []
272
  seen_labels = set()
273
  for index, row in unique_entities.iterrows():
274
+ label = row['label'] # 'label' is defined here
275
  if label not in seen_labels:
276
  seen_labels.add(label)
277
  color = entity_color_map.get(label, '#cccccc')
 
832
  height=800,
833
  scrolling=True
834
  )