feat(vocab): enrich core patterns with glosses in VocabService and VocabLessonView
All checks were successful
Deploy to production / deploy (push) Successful in 2m54s

- Implemented a new method in VocabService to enhance core patterns with glosses derived from extracted vocabulary, improving the clarity of vocabulary entries.
- Updated the VocabLessonView to utilize the enriched core patterns, ensuring that glosses are displayed alongside vocabulary targets for better user comprehension.
- Refactored vocabulary preparation logic to integrate glosses seamlessly, enhancing the overall user experience during vocabulary lessons.
This commit is contained in:
Torsten Schulz (local)
2026-04-01 09:40:33 +02:00
parent 02b3636e10
commit 1328e4983e
2 changed files with 47 additions and 3 deletions

View File

@@ -948,7 +948,18 @@ export default {
},
prepItems() {
if (this.normalizedCorePatterns.length > 0) {
return this.normalizedCorePatterns;
const glossByReference = new Map(
(this.importantVocab || [])
.map((item) => [String(item?.reference || '').trim().toLowerCase(), String(item?.learning || '').trim()])
.filter(([reference, learning]) => reference && learning)
);
return this.normalizedCorePatterns.map((item) => {
if (item.gloss) {
return item;
}
const gloss = glossByReference.get(String(item.target || '').trim().toLowerCase()) || '';
return gloss ? { ...item, gloss } : item;
});
}
return (this.importantVocab || [])
.map((item) => ({