Review CM1/CM2 content: fix ambiguities, hints, final punctuation in corrections (0.8.2)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Denis Defolie
2026-10-12 12:01:21 +02:00
parent 8584249d78
commit a91d9e528c
27 changed files with 111 additions and 77 deletions
+12 -2
View File
@@ -73,13 +73,23 @@ static func validate_sentence_correction(
## (« achèterais ») : une reponse ambigue n'est pas declaree fausse
## automatiquement (CLAUDE.md, invariants pedagogiques).
static func _matches_expected(submitted: String, expected: String, token_text: String = "") -> bool:
var typed := TextNormalizer.normalize(submitted).to_lower()
var typed := _comparable(submitted)
for form in _accepted_forms(expected, token_text):
if typed == TextNormalizer.normalize(form).to_lower():
if typed == _comparable(form):
return true
return false
## Forme comparable : normalisee, en minuscules, sans ponctuation finale. Le
## mot touche porte parfois le point de la phrase (« roze. ») ; l'enfant n'a
## pas a le retaper, et le taper n'est pas une erreur.
static func _comparable(text: String) -> String:
var cleaned := TextNormalizer.normalize(text).to_lower()
while not cleaned.is_empty() and ".,;:!?…".contains(cleaned[cleaned.length() - 1]):
cleaned = cleaned.substr(0, cleaned.length() - 1).strip_edges()
return cleaned
## Formes acceptees : l'attendu, sans son prefixe d'elision (« j' », « l' »...),
## ou avec le prefixe du mot touche quand l'attendu n'en porte pas.
static func _accepted_forms(expected: String, token_text: String) -> Array[String]: