feat: Erweiterung der akzeptierten Antworten im Vokabeltrainer durch Deduplizierung und Variantenaufspaltung
All checks were successful
Deploy to production / deploy (push) Successful in 2m13s
All checks were successful
Deploy to production / deploy (push) Successful in 2m13s
This commit is contained in:
@@ -3972,16 +3972,23 @@ export default {
|
|||||||
const allTrainerVocabs = pool;
|
const allTrainerVocabs = pool;
|
||||||
const direction = this.vocabTrainerDirection;
|
const direction = this.vocabTrainerDirection;
|
||||||
const prompt = direction === 'L2R' ? vocab.learning : vocab.reference;
|
const prompt = direction === 'L2R' ? vocab.learning : vocab.reference;
|
||||||
const acceptableAnswers = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs);
|
const rawAcceptable = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs);
|
||||||
|
// Expand variants (split slashes / parentheses) and dedupe by normalized form
|
||||||
|
const expanded = rawAcceptable.flatMap(a => this.expandAnswerVariants(a));
|
||||||
|
const seen = new Set();
|
||||||
|
const finalAnswers = [];
|
||||||
|
for (const a of expanded) {
|
||||||
|
const n = this.normalizeVocab(a);
|
||||||
|
if (!n || seen.has(n)) continue;
|
||||||
|
seen.add(n);
|
||||||
|
finalAnswers.push(a);
|
||||||
|
}
|
||||||
|
const fallback = direction === 'L2R' ? vocab.reference : vocab.learning;
|
||||||
this.currentVocabQuestion = {
|
this.currentVocabQuestion = {
|
||||||
vocab,
|
vocab,
|
||||||
prompt,
|
prompt,
|
||||||
answers: acceptableAnswers.length > 0
|
answers: finalAnswers.length > 0 ? finalAnswers : [fallback],
|
||||||
? acceptableAnswers
|
answer: finalAnswers.length > 0 ? finalAnswers.join(' / ') : fallback,
|
||||||
: [direction === 'L2R' ? vocab.reference : vocab.learning],
|
|
||||||
answer: acceptableAnswers.length > 0
|
|
||||||
? acceptableAnswers.join(' / ')
|
|
||||||
: (direction === 'L2R' ? vocab.reference : vocab.learning),
|
|
||||||
key: this.getVocabKey(vocab),
|
key: this.getVocabKey(vocab),
|
||||||
source: 'hard'
|
source: 'hard'
|
||||||
};
|
};
|
||||||
@@ -4072,9 +4079,10 @@ export default {
|
|||||||
: [vocab.learning]);
|
: [vocab.learning]);
|
||||||
const equivalentAnswers = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs);
|
const equivalentAnswers = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs);
|
||||||
const mergedRaw = [...baseAnswers, ...equivalentAnswers].filter(Boolean);
|
const mergedRaw = [...baseAnswers, ...equivalentAnswers].filter(Boolean);
|
||||||
|
const expandedMerged = mergedRaw.flatMap(a => this.expandAnswerVariants(a));
|
||||||
const seenNorm = new Set();
|
const seenNorm = new Set();
|
||||||
const acceptableAnswers = [];
|
const acceptableAnswers = [];
|
||||||
for (const a of mergedRaw) {
|
for (const a of expandedMerged) {
|
||||||
const n = this.normalizeVocab(a);
|
const n = this.normalizeVocab(a);
|
||||||
if (!n || seenNorm.has(n)) continue;
|
if (!n || seenNorm.has(n)) continue;
|
||||||
seenNorm.add(n);
|
seenNorm.add(n);
|
||||||
|
|||||||
Reference in New Issue
Block a user