fix: ignore apostrophes in practice answers

This commit is contained in:
TTlaji committed 2026-06-08 15:19:05 +08:00
1 parent a6ac042e83
commit d78ddc7e00
2 files changed
+10 -3

No files matched your search

+2 -2
View File
@@ -801,10 +801,10 @@ const practiceModeLabels = {
function normalizePracticeAnswer(text) { function normalizePracticeAnswer(text) {
return String(text || "") return String(text || "")
.toLowerCase() .toLowerCase()
.replace(/[’‘]/g, "'") .replace(/['’‘]/g, "")
.replace(/[“”]/g, "\"") .replace(/[“”]/g, "\"")
.replace(/[-–—]+/g, " ") .replace(/[-–—]+/g, " ")
.replace(/[.,!?;:"()[\]{},。!?;:“”‘’、]/g, " ") .replace(/[.,!?;:"()[\]{},。!?;:“”、]/g, " ")
.replace(/\s+/g, " ") .replace(/\s+/g, " ")
.trim(); .trim();
} }
+8 -1
View File
@@ -7,7 +7,7 @@ import {
} from "../app.js"; } from "../app.js";
assert.equal(normalizePracticeAnswer(" Hello, WORLD! "), "hello world"); assert.equal(normalizePracticeAnswer(" Hello, WORLD! "), "hello world");
assert.equal(normalizePracticeAnswer("I’m ready."), "i'm ready"); assert.equal(normalizePracticeAnswer("I’m ready."), "im ready");
assert.equal(normalizePracticeAnswer("Are you ok? Yes!"), "are you ok yes"); assert.equal(normalizePracticeAnswer("Are you ok? Yes!"), "are you ok yes");
assert.equal(normalizePracticeAnswer("Listen--then write"), "listen then write"); assert.equal(normalizePracticeAnswer("Listen--then write"), "listen then write");
@@ -32,6 +32,13 @@ assert.deepEqual(comparePracticeAnswer("Good technology should help!", "Good tec
message: "完全匹配。", message: "完全匹配。",
}); });
assert.deepEqual(comparePracticeAnswer("dont stop", "Don’t stop."), {
status: "correct",
isCorrect: true,
reference: "Don’t stop.",
message: "完全匹配。",
});
assert.deepEqual(comparePracticeAnswer("Good tools help.", "Good technology should help."), { assert.deepEqual(comparePracticeAnswer("Good tools help.", "Good technology should help."), {
status: "incorrect", status: "incorrect",
isCorrect: false, isCorrect: false,