feat(vocab): improve vocabulary preparation logic in VocabLessonView
All checks were successful
Deploy to production / deploy (push) Successful in 2m44s
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user