Ground the judge's quote with markdown emphasis and whitespace ignored
This commit is contained in:
@@ -94,4 +94,10 @@ def verdict_from(output) -> Verdict | Failure:
|
||||
|
||||
|
||||
def grounded(verdict, transcript) -> bool:
|
||||
return verdict.evidence.strip() != "" and verdict.evidence in transcript
|
||||
evidence = plain(verdict.evidence)
|
||||
return evidence != "" and evidence in plain(transcript)
|
||||
|
||||
|
||||
def plain(text) -> str:
|
||||
# The judge drops markdown emphasis and reflows whitespace when it quotes.
|
||||
return " ".join(text.replace("*", "").replace("_", "").split())
|
||||
|
||||
@@ -104,6 +104,10 @@ class Grounded(unittest.TestCase):
|
||||
self.assertFalse(judge.grounded(verdict("invented"), "the transcript"))
|
||||
self.assertFalse(judge.grounded(verdict(""), "the transcript"))
|
||||
self.assertFalse(judge.grounded(verdict(" "), "the transcript"))
|
||||
transcript = "done.\n\n**Your step:**\n```\n./run.sh\n```\nRun it."
|
||||
self.assertTrue(judge.grounded(verdict("Your step:\n```\n./run.sh\n```\nRun it."), transcript))
|
||||
self.assertTrue(judge.grounded(verdict("Your step: ``` ./run.sh ``` Run it."), transcript))
|
||||
self.assertFalse(judge.grounded(verdict("**"), transcript))
|
||||
|
||||
|
||||
class Verdict(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user