frontend: treat trailing parenthetical notes as optional in vocab matching
Some checks failed
Deploy to production / deploy (push) Has been cancelled

This commit is contained in:
Torsten Schulz (local)
2026-05-21 10:50:15 +02:00
parent ad0ccd0281
commit 4abed5263e

View File

@@ -4154,7 +4154,7 @@ export default {
return text; return text;
}, },
normalizeVocab(s, options = {}) { normalizeVocab(s, options = {}) {
const { ignoreTrailingParentheticalNotes = false } = options; const { ignoreTrailingParentheticalNotes = true } = options;
const source = ignoreTrailingParentheticalNotes const source = ignoreTrailingParentheticalNotes
? this.stripTrailingParentheticalNotes(s) ? this.stripTrailingParentheticalNotes(s)
: s; : s;
@@ -4250,15 +4250,13 @@ export default {
userAnswer = this.vocabTrainerAnswer; userAnswer = this.vocabTrainerAnswer;
} }
const useTypingNormalization = this.vocabTrainerMode === 'typing'; // Treat parenthetical notes as optional for answer matching.
const normalizedUser = this.normalizeVocab(userAnswer, { const normalizedUser = this.normalizeVocab(userAnswer);
ignoreTrailingParentheticalNotes: useTypingNormalization
});
const rawAnswers = this.currentVocabQuestion.answers || [this.currentVocabQuestion.answer]; const rawAnswers = this.currentVocabQuestion.answers || [this.currentVocabQuestion.answer];
// Expand alternatives like "A / B" into separate acceptable answers // Expand alternatives like "A / B" into separate acceptable answers
const expandedAnswers = rawAnswers.flatMap(a => this.expandAnswerVariants(a)); const expandedAnswers = rawAnswers.flatMap(a => this.expandAnswerVariants(a));
const normalizedCorrectAnswers = expandedAnswers const normalizedCorrectAnswers = expandedAnswers
.map(answer => this.normalizeVocab(answer, { ignoreTrailingParentheticalNotes: useTypingNormalization })); .map(answer => this.normalizeVocab(answer));
this.vocabTrainerLastCorrect = normalizedCorrectAnswers.includes(normalizedUser); this.vocabTrainerLastCorrect = normalizedCorrectAnswers.includes(normalizedUser);
// Update Stats // Update Stats