feat(vocab): improve vocabulary preparation logic in VocabLessonView
All checks were successful
Deploy to production / deploy (push) Successful in 2m44s

- Refactored prepItems method to ensure only valid target-gloss pairs are included, enhancing the quality of vocabulary preparation.
- Introduced a mechanism to limit the output to a maximum of 30 unique pairs, improving the compactness of the preparation round.
- Enhanced handling of core patterns and extracted vocabulary to prioritize high-quality learning materials.
This commit is contained in:
Torsten Schulz (local)
2026-04-07 09:58:33 +02:00
parent 86dfb0d859
commit 62503191d4

View File

@@ -1296,12 +1296,32 @@ export default {
.filter(Boolean);
},
prepItems() {
return this.lessonVocab
.map((item) => ({
target: String(item?.reference || '').trim(),
gloss: String(item?.learning || '').trim()
}))
.filter((item) => item.target);
// Vorbereitung nur mit echten Paaren (Zielsprache + Übersetzung),
// damit weder leere Gloss-Zeilen noch übergroße Listen entstehen.
const out = [];
const seen = new Set();
const pushUnique = (target, gloss) => {
const t = String(target || '').trim();
const g = String(gloss || '').trim();
if (!t || !g) return;
const key = `${this.normalizeLessonVocabTerm(t)}|${this.normalizeLessonVocabTerm(g)}`;
if (seen.has(key)) return;
seen.add(key);
out.push({ target: t, gloss: g });
};
// 1) Didaktisch gepflegte Kernmuster zuerst (höchste Qualität)
this.normalizedCorePatterns.forEach((p) => {
pushUnique(p?.target, p?.gloss);
});
// 2) Ergänzung aus extrahierten Übungsvokabeln, aber nur saubere Paare
this.lessonVocab.forEach((item) => {
pushUnique(item?.reference, item?.learning);
});
// Begrenzen, damit die Vorbereitungsrunde kompakt bleibt
return out.slice(0, 30);
},
currentPrepItem() {
return this.prepItems[this.lessonPrepIndex] || null;