Source Code
consequence_scorer.py
class ConsequenceScorer:
def __init__(self, category_weights: dict):
self.weights = category_weights
def score(self, output, example):
category = example.get("category", "general")
weight = self.weights.get(category, 1.0)
# Simplified exact match for demo
is_correct = output.strip().lower() == example["expected"].strip().lower()
base_score = 1.0 if is_correct else 0.0
return {
"accuracy": base_score,
"weighted_score": base_score * weight,
"weight_applied": weight
}