mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 10:21:58 +02:00
8a3469e7b1
Follow-up to the previous commit: testing further showed a missing
initial capital also fails validation, which raised the real
question (CLAUDE.md: ask rather than decide alone on an ambiguous
pedagogical point) — is sentence-initial capitalization and final
punctuation something the audio should convey, or a general writing
convention the child applies regardless of what they hear?
Decided: a general convention, like in a real classroom dictée. So
both stay required, and the terminal-punctuation tolerance added in
the previous commit is reverted (DictationAnalyzer back to comparing
the text as-is).
Since the audio still can't vocalize either rule, the child needs to
be told some other way: added a permanent reminder label to the
dictation scene ("N'oublie pas : une majuscule au début de la phrase
et un point à la fin !"), sourced from data/localization/fr.json.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
80 lines
3.2 KiB
GDScript
80 lines
3.2 KiB
GDScript
extends GutTest
|
||
## Tests de DictationAnalyzer : alignement, classification lexicale/grammaticale
|
||
## via annotation, majuscule, variantes acceptees.
|
||
|
||
var dictation: Dictionary = {
|
||
"target_text": "Les petits chats dorment.",
|
||
"words":
|
||
[
|
||
{"text": "Les", "expects_capital": true},
|
||
{"text": "petits", "rule_id": "regle_accord_adjectif"},
|
||
{"text": "chats"},
|
||
{"text": "dorment."},
|
||
],
|
||
"accepted_variants": [],
|
||
}
|
||
|
||
|
||
func test_exact_match_is_correct() -> void:
|
||
var result := DictationAnalyzer.analyze(dictation, "Les petits chats dorment.")
|
||
assert_true(result.is_correct)
|
||
assert_eq(result.errors, [])
|
||
|
||
|
||
func test_annotated_word_error_is_classified_as_grammatical() -> void:
|
||
var result := DictationAnalyzer.analyze(dictation, "Les petit chats dorment.")
|
||
assert_false(result.is_correct)
|
||
assert_eq(result.errors.size(), 1)
|
||
assert_eq(result.errors[0]["error_type"], "grammatical")
|
||
assert_eq(result.errors[0]["rule_id"], "regle_accord_adjectif")
|
||
assert_eq(result.errors[0]["found"], "petit")
|
||
assert_eq(result.errors[0]["expected"], "petits")
|
||
|
||
|
||
func test_unannotated_word_error_is_unclassified() -> void:
|
||
var result := DictationAnalyzer.analyze(dictation, "Les petits chat dorment.")
|
||
assert_false(result.is_correct)
|
||
assert_eq(result.errors.size(), 1)
|
||
assert_eq(result.errors[0]["error_type"], "unclassified")
|
||
assert_eq(result.errors[0]["rule_id"], "")
|
||
|
||
|
||
func test_missing_word_does_not_cascade_into_further_errors() -> void:
|
||
# Le mot "petits" est omis : sans alignement, cela provoquerait deux
|
||
# erreurs en cascade sur "chats" et "dorment.".
|
||
var result := DictationAnalyzer.analyze(dictation, "Les chats dorment.")
|
||
assert_false(result.is_correct)
|
||
assert_eq(result.errors.size(), 1)
|
||
assert_eq(result.errors[0]["rule_id"], "regle_accord_adjectif")
|
||
|
||
|
||
func test_missing_capital_is_reported_separately() -> void:
|
||
var result := DictationAnalyzer.analyze(dictation, "les petits chats dorment.")
|
||
assert_false(result.is_correct)
|
||
assert_eq(result.errors.size(), 1)
|
||
assert_eq(result.errors[0]["error_type"], "capitalization")
|
||
|
||
|
||
func test_accepted_variant_is_treated_as_correct() -> void:
|
||
var dictation_with_variant: Dictionary = dictation.duplicate(true)
|
||
dictation_with_variant["accepted_variants"] = ["Les petits chats dorment"]
|
||
var result := DictationAnalyzer.analyze(dictation_with_variant, "Les petits chats dorment")
|
||
assert_true(result.is_correct)
|
||
|
||
|
||
func test_normalizes_before_comparing() -> void:
|
||
var result := DictationAnalyzer.analyze(dictation, "Les petits chats dorment.")
|
||
assert_true(result.is_correct)
|
||
|
||
|
||
## Majuscule initiale et point final sont des conventions generales d'ecriture
|
||
## (voir docs/specs/decisions.md, point 22), exigees comme n'importe quel
|
||
## autre mot : l'enfant en est informe par un rappel affiche, pas par une
|
||
## tolerance a la correction.
|
||
func test_missing_terminal_punctuation_is_an_error() -> void:
|
||
var result := DictationAnalyzer.analyze(dictation, "Les petits chats dorment")
|
||
assert_false(result.is_correct)
|
||
assert_eq(result.errors.size(), 1)
|
||
assert_eq(result.errors[0]["found"], "dorment")
|
||
assert_eq(result.errors[0]["expected"], "dorment.")
|