feat(VocabPracticeDialog): enhance answer variant expansion logic
All checks were successful
Deploy to production / deploy (push) Successful in 1m51s
All checks were successful
Deploy to production / deploy (push) Successful in 1m51s
- Renamed `expandAnswerVariants` to `expandSingleAnswerVariants` for clarity and added a new `expandAnswerVariants` method to handle full-answer alternatives like "A / B". - Improved the logic to ensure that phrase alternatives are expanded correctly, enhancing the accuracy of answer variant generation during vocabulary practice.
This commit is contained in:
@@ -719,7 +719,7 @@ export default {
|
||||
}
|
||||
return Array.from(answers);
|
||||
},
|
||||
expandAnswerVariants(answer) {
|
||||
expandSingleAnswerVariants(answer) {
|
||||
const base = String(answer || '').trim();
|
||||
if (!base) return [];
|
||||
|
||||
@@ -760,6 +760,24 @@ export default {
|
||||
|
||||
return [...new Set([base, ...variants])];
|
||||
},
|
||||
expandAnswerVariants(answer) {
|
||||
const base = String(answer || '').trim();
|
||||
if (!base) return [];
|
||||
|
||||
// Handle full-answer alternatives like "A / B" as separate valid answers.
|
||||
// Word-level slash expansion alone does not cover this reliably.
|
||||
const phraseAlternatives = base
|
||||
.split(/\s+\/\s+/)
|
||||
.map((part) => String(part || '').trim())
|
||||
.filter(Boolean);
|
||||
|
||||
if (phraseAlternatives.length >= 2) {
|
||||
const expanded = phraseAlternatives.flatMap((part) => this.expandSingleAnswerVariants(part));
|
||||
return [...new Set(expanded)];
|
||||
}
|
||||
|
||||
return this.expandSingleAnswerVariants(base);
|
||||
},
|
||||
computeWeight(item) {
|
||||
const st = this.perId[item.id] || { c: 0, w: 0, streak: 0, lastAsked: 0 };
|
||||
let w = 1;
|
||||
|
||||
Reference in New Issue
Block a user