Ryan commited on
Commit
b3c9add
·
1 Parent(s): 2031ee5
Files changed (1) hide show
  1. processors/bias_processor.py +16 -15
processors/bias_processor.py CHANGED
@@ -121,22 +121,23 @@ The overall bias difference is {bias_results['comparative']['overall']['differen
121
  fig3 = make_subplots(rows=1, cols=2, subplot_titles=models)
122
 
123
  for i, model in enumerate(models):
124
- # Fix: Instead of directly accessing 'frame_counts', extract counts from frame_counts data
125
- # Check if the data structure has 'frame_counts' key, otherwise use 'frames' directly
126
- if 'frame_counts' in bias_results[model]['framing']:
127
- frame_counts = bias_results[model]['framing']['frame_counts']
 
 
 
 
128
  else:
129
- # Assuming frames data is available directly in the 'framing' section
130
- frame_data = bias_results[model]['framing'].get('frames', {})
131
- # If not found, try to reconstruct from log data
132
- if not frame_data:
133
- # Use the information from logs to construct a minimal frame counts
134
- frame_counts = {}
135
- for frame in frames:
136
- # Default to 0 or try to get count from other available sources
137
- frame_counts[frame] = bias_results[model]['framing'].get(frame, 0)
138
- else:
139
- frame_counts = frame_data
140
 
141
  # Add trace for each model
142
  fig3.add_trace(
 
121
  fig3 = make_subplots(rows=1, cols=2, subplot_titles=models)
122
 
123
  for i, model in enumerate(models):
124
+ # Improved handling of framing data
125
+ # First, try to get the framing_counts directly
126
+ if 'framing_counts' in bias_results[model]['framing']:
127
+ frame_counts = bias_results[model]['framing']['framing_counts']
128
+ # Fall back to frames if framing_counts not available
129
+ elif 'frames' in bias_results[model]['framing']:
130
+ frame_counts = bias_results[model]['framing']['frames']
131
+ # Last resort: create a default structure with zeros
132
  else:
133
+ frame_counts = {frame: 0 for frame in frames}
134
+ # Try to populate with any available data
135
+ for frame in frames:
136
+ count = bias_results[model]['framing'].get(frame, 0)
137
+ if count > 0:
138
+ frame_counts[frame] = count
139
+
140
+ logger.info(f"Frame counts for {model}: {frame_counts}")
 
 
 
141
 
142
  # Add trace for each model
143
  fig3.add_trace(