ajaxwin
task2 reviewed, semanticmatcher implemented
cf983b8
raw
history blame
1.5 kB
"""
grader.py (Task 2 – Property Discovery)
-----------------------------------------
Deterministic scorer for natural-language property submissions.
One submission attempt per episode.
"""
from __future__ import annotations
from typing import Tuple
from utils import SemanticMatcher
# ── Grader ────────────────────────────────────────────────────────────────────
class Task2Grader:
"""
Grades a Task 2 property submission.
Parameters
----------
function_name : name of the target function
property : the 'property' field from the target function's data
"""
def __init__(self, function_name: str, property: str) -> None:
self.function_name = function_name
self.property = property
# ── Public API ────────────────────────────────────────────────────────────
def grade(self, submitted: str) -> Tuple[float, str]:
"""Deterministic score in [0.0, 1.0]."""
if not submitted or not submitted.strip():
return 0.0, "no_match"
SemanticMatcherInstance = SemanticMatcher()
return (
SemanticMatcherInstance.matchscore(self.property, submitted),
SemanticMatcherInstance.confidence()
)