← Lesson
Ground the Judge
Joeven
Run
Reset
Python loads on first run
def judge(answer, cited, source_ids, text): errors = [] for sid in cited: if sid not in source_ids: errors.append("unknown cite " + sid) if not cited: errors.append("no cites") for sid in cited: if sid in source_ids and source_ids[sid].split()[0].lower() not in answer.lower(): errors.append("ignores " + sid) if errors: return {"ok": False, "errors": errors, "winner": "human"} return {"ok": True, "errors": [], "winner": "proposer"} SRCS = {"s1": "Paris rain 12C", "s2": "No cash after 30 days"} print(judge("Paris rain 12C. No cash after 30 days.", ["s1", "s2"], SRCS, "")) print(judge("Bring shorts, it is hot.", ["s1"], SRCS, "")) print(judge("Paris rain 12C.", ["s9"], SRCS, ""))
Run to execute this in your browser. Nothing is sent to a server.