Spaces:
Running
Running
File size: 1,496 Bytes
9c888b7 cf983b8 9c888b7 cf983b8 9c888b7 cf983b8 9c888b7 cf983b8 9c888b7 cf983b8 9c888b7 cf983b8 9c888b7 cf983b8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | """
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()
) |