Narrowed the grammar module LLM prompt and added support for a <-> an replacements
This commit is contained in:
@@ -361,6 +361,46 @@ def test_grammar_only_validator_allows_formatting_only_changes(tmp_path):
|
||||
]
|
||||
|
||||
|
||||
def test_grammar_only_validator_allows_indefinite_article_changes(tmp_path):
|
||||
transcript = parse_transcript_json(
|
||||
"""
|
||||
[
|
||||
{"id": 1, "speaker": "A", "start": 0.0, "end": 1.0, "text": "a intelligence saving throw"},
|
||||
{"id": 2, "speaker": "A", "start": 1.0, "end": 2.0, "text": "an owl"}
|
||||
]
|
||||
"""
|
||||
)
|
||||
proposals = [
|
||||
CorrectionProposal(
|
||||
proposal_index=0,
|
||||
module_instance="grammar",
|
||||
module_key="grammar",
|
||||
id=1,
|
||||
original_text="a intelligence saving throw",
|
||||
corrected_text="an intelligence saving throw",
|
||||
confidence=0.95,
|
||||
),
|
||||
CorrectionProposal(
|
||||
proposal_index=1,
|
||||
module_instance="grammar",
|
||||
module_key="grammar",
|
||||
id=2,
|
||||
original_text="an owl",
|
||||
corrected_text="a owl",
|
||||
confidence=0.95,
|
||||
),
|
||||
]
|
||||
|
||||
result = GrammarOnlyValidator("grammar_only_guard").validate(
|
||||
_context(proposals=proposals, transcript=transcript, llm_client=None, tmp_path=tmp_path)
|
||||
)
|
||||
|
||||
assert [(decision.proposal_index, decision.approved) for decision in result.decisions] == [
|
||||
(0, True),
|
||||
(1, True),
|
||||
]
|
||||
|
||||
|
||||
def test_grammar_only_validator_rejects_word_level_changes(tmp_path):
|
||||
transcript = parse_transcript_json(
|
||||
"""
|
||||
@@ -368,7 +408,8 @@ def test_grammar_only_validator_rejects_word_level_changes(tmp_path):
|
||||
{"id": 1, "speaker": "A", "start": 0.0, "end": 1.0, "text": "their plan"},
|
||||
{"id": 2, "speaker": "A", "start": 1.0, "end": 2.0, "text": "dam"},
|
||||
{"id": 3, "speaker": "A", "start": 2.0, "end": 3.0, "text": "uh"},
|
||||
{"id": 4, "speaker": "A", "start": 3.0, "end": 4.0, "text": "I I agree"}
|
||||
{"id": 4, "speaker": "A", "start": 3.0, "end": 4.0, "text": "I I agree"},
|
||||
{"id": 5, "speaker": "A", "start": 4.0, "end": 5.0, "text": "Eric"}
|
||||
]
|
||||
"""
|
||||
)
|
||||
@@ -409,13 +450,22 @@ def test_grammar_only_validator_rejects_word_level_changes(tmp_path):
|
||||
corrected_text="I",
|
||||
confidence=0.95,
|
||||
),
|
||||
CorrectionProposal(
|
||||
proposal_index=4,
|
||||
module_instance="grammar",
|
||||
module_key="grammar",
|
||||
id=5,
|
||||
original_text="Eric",
|
||||
corrected_text="Eric's",
|
||||
confidence=0.95,
|
||||
),
|
||||
]
|
||||
|
||||
result = GrammarOnlyValidator("grammar_only_guard").validate(
|
||||
_context(proposals=proposals, transcript=transcript, llm_client=None, tmp_path=tmp_path)
|
||||
)
|
||||
|
||||
assert [decision.approved for decision in result.decisions] == [False, False, False, False]
|
||||
assert [decision.approved for decision in result.decisions] == [False, False, False, False, False]
|
||||
assert all(
|
||||
decision.reason == "correction is not limited to punctuation, capitalization, and spacing"
|
||||
for decision in result.decisions
|
||||
|
||||
Reference in New Issue
Block a user