fix: ignore apostrophes in practice answers
This commit is contained in:
1 parent
a6ac042e83
commit
d78ddc7e00
2 files changed
+10
-3
No files matched your search
@@ -801,10 +801,10 @@ const practiceModeLabels = {
|
||||
function normalizePracticeAnswer(text) {
|
||||
return String(text || "")
|
||||
.toLowerCase()
|
||||
.replace(/[’‘]/g, "'")
|
||||
.replace(/['’‘]/g, "")
|
||||
.replace(/[“”]/g, "\"")
|
||||
.replace(/[-–—]+/g, " ")
|
||||
.replace(/[.,!?;:"()[\]{},。!?;:“”‘’、]/g, " ")
|
||||
.replace(/[.,!?;:"()[\]{},。!?;:“”、]/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "../app.js";
|
||||
|
||||
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("Listen--then write"), "listen then write");
|
||||
|
||||
@@ -32,6 +32,13 @@ assert.deepEqual(comparePracticeAnswer("Good technology should help!", "Good tec
|
||||
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."), {
|
||||
status: "incorrect",
|
||||
isCorrect: false,
|
||||
|
||||
Reference in new issue
Block a user