192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318 | def aggregate_by_institution(combined_data):
"""Aggregate individual rankings by institution affiliation."""
inst_data = defaultdict(
lambda: {
"affiliation": "",
"combined_score": 0,
"artifact_score": 0,
"artifact_citations": 0,
"citation_score": 0,
"ae_score": 0,
"artifact_count": 0,
"badges_functional": 0,
"badges_reproducible": 0,
"ae_memberships": 0,
"chair_count": 0,
"total_papers": 0,
"author_count": 0,
"conferences": set(),
"years": defaultdict(int),
}
)
for person in combined_data:
affiliation = _normalize_affiliation(person.get("affiliation", "").strip())
# Skip entries with no affiliation or placeholder affiliations
if not affiliation or affiliation == "Unknown" or affiliation.startswith("_"):
affiliation = "Unknown"
inst = inst_data[affiliation]
inst["affiliation"] = affiliation
inst["combined_score"] += person.get("combined_score", 0)
inst["artifact_score"] += person.get("artifact_score", 0)
inst["artifact_citations"] += person.get("artifact_citations", 0)
inst["citation_score"] += person.get("citation_score", 0)
inst["ae_score"] += person.get("ae_score", 0)
inst["artifact_count"] += person.get("artifact_count", 0)
inst["badges_functional"] += person.get("badges_functional", 0)
inst["badges_reproducible"] += person.get("badges_reproducible", 0)
inst["ae_memberships"] += person.get("ae_memberships", 0)
inst["chair_count"] += person.get("chair_count", 0)
inst["total_papers"] += person.get("total_papers", 0)
inst["author_count"] += 1
# Aggregate conferences
if person.get("conferences"):
inst["conferences"].update(person["conferences"])
# Aggregate years
if person.get("years"):
for year, count in person["years"].items():
inst["years"][year] += count
# Convert to list and calculate derived fields
institutions = []
for affiliation, data in inst_data.items():
if data["artifact_count"] > data["total_papers"]:
raise ValueError(
f"Invariant violation for institution '{affiliation}': artifact_count ({data['artifact_count']}) > total_papers ({data['total_papers']})"
)
if data["badges_reproducible"] > data["artifact_count"]:
raise ValueError(
f"Invariant violation for institution '{affiliation}': reproduced_badges ({data['badges_reproducible']}) > artifact_count ({data['artifact_count']})"
)
if data["badges_functional"] > data["artifact_count"]:
raise ValueError(
f"Invariant violation for institution '{affiliation}': functional_badges ({data['badges_functional']}) > artifact_count ({data['artifact_count']})"
)
# Calculate artifact rate
artifact_pct = 0
if data["total_papers"] > 0:
artifact_pct = round((data["artifact_count"] / data["total_papers"]) * 100, 1)
# Calculate A:E ratio
ae_ratio = None
if data["ae_score"] > 0:
ae_ratio = round(data["artifact_score"] / data["ae_score"], 2)
elif data["artifact_score"] > 0:
ae_ratio = None # Artifact-only, will display as ∞
else:
ae_ratio = 0.0 # Neither artifacts nor AE service
# Classify institution role based on A:E ratio
if ae_ratio is None:
# Artifact-only (ae_score == 0, artifact_score > 0) → creator
role = "Producer"
elif ae_ratio == 0.0:
# AE-only or neither (artifact_score == 0) → evaluator
role = "Consumer"
elif ae_ratio > 2.0:
role = "Producer"
elif ae_ratio < 0.5:
role = "Consumer"
else:
role = "Balanced"
# Only include institutions with meaningful contributions, excluding incomplete affiliations
if data["combined_score"] >= 3 and affiliation.strip() not in ("Univ", "University", "Unknown", "_"):
institutions.append(
{
"affiliation": data["affiliation"],
"combined_score": data["combined_score"],
"artifact_score": data["artifact_score"],
"artifact_citations": data["artifact_citations"],
"citation_score": data["citation_score"],
"ae_score": data["ae_score"],
"ae_ratio": ae_ratio,
"role": role,
"artifact_count": data["artifact_count"],
"badges_functional": data["badges_functional"],
"badges_reproducible": data["badges_reproducible"],
"ae_memberships": data["ae_memberships"],
"chair_count": data["chair_count"],
"total_papers": data["total_papers"],
"artifact_pct": artifact_pct,
"author_count": data["author_count"],
"conferences": sorted(list(data["conferences"])),
"years": {str(k): v for k, v in data["years"].items()},
"top_authors": [],
}
)
# Sort by combined_score descending
institutions.sort(key=lambda x: x["combined_score"], reverse=True)
return institutions
|