@@ -171,7 +171,7 @@ function getPublicContext(context) {
171171
172172/**
173173 * @param {import('dictionary').TermDictionaryEntry|import('dictionary').KanjiDictionaryEntry } dictionaryEntry
174- * @returns {number [] }
174+ * @returns {import('anki-templates').FrequencyNumber [] }
175175 */
176176function getFrequencyNumbers ( dictionaryEntry ) {
177177 let previousDictionary ;
@@ -187,13 +187,13 @@ function getFrequencyNumbers(dictionaryEntry) {
187187 if ( frequencyMatch !== null ) {
188188 const frequencyParsed = Number . parseInt ( frequencyMatch [ 0 ] , 10 ) ;
189189 if ( frequencyParsed > 0 ) {
190- frequencies . push ( frequencyParsed ) ;
190+ frequencies . push ( { dictionary : dictionary , frequency : frequencyParsed } ) ;
191191 continue ;
192192 }
193193 }
194194 }
195195 if ( frequency > 0 ) {
196- frequencies . push ( frequency ) ;
196+ frequencies . push ( { dictionary : dictionary , frequency : frequency } ) ;
197197 }
198198 }
199199 return frequencies ;
@@ -212,7 +212,7 @@ function getFrequencyHarmonic(dictionaryEntry) {
212212
213213 let total = 0 ;
214214 for ( const frequency of frequencies ) {
215- total += 1 / frequency ;
215+ total += 1 / frequency . frequency ;
216216 }
217217 return Math . floor ( frequencies . length / total ) ;
218218}
@@ -230,7 +230,7 @@ function getFrequencyAverage(dictionaryEntry) {
230230
231231 let total = 0 ;
232232 for ( const frequency of frequencies ) {
233- total += frequency ;
233+ total += frequency . frequency ;
234234 }
235235 return Math . floor ( total / frequencies . length ) ;
236236}
@@ -441,6 +441,7 @@ function getTermDefinition(dictionaryEntry, context, resultOutputMode, dictionar
441441 const termTags = createCachedValue ( getTermTags . bind ( null , dictionaryEntry , type ) ) ;
442442 const expressions = createCachedValue ( getTermExpressions . bind ( null , dictionaryEntry ) ) ;
443443 const frequencies = createCachedValue ( getTermFrequencies . bind ( null , dictionaryEntry ) ) ;
444+ const frequencyNumbers = createCachedValue ( getFrequencyNumbers . bind ( null , dictionaryEntry ) ) ;
444445 const frequencyHarmonic = createCachedValue ( getFrequencyHarmonic . bind ( null , dictionaryEntry ) ) ;
445446 const frequencyAverage = createCachedValue ( getFrequencyAverage . bind ( null , dictionaryEntry ) ) ;
446447 const pitches = createCachedValue ( getTermPitches . bind ( null , dictionaryEntry ) ) ;
@@ -483,6 +484,7 @@ function getTermDefinition(dictionaryEntry, context, resultOutputMode, dictionar
483484 get termTags ( ) { return getCachedValue ( termTags ) ; } ,
484485 get definitions ( ) { return getCachedValue ( commonInfo ) . definitions ; } ,
485486 get frequencies ( ) { return getCachedValue ( frequencies ) ; } ,
487+ get frequencyNumbers ( ) { return getCachedValue ( frequencyNumbers ) ; } ,
486488 get frequencyHarmonic ( ) { return getCachedValue ( frequencyHarmonic ) ; } ,
487489 get frequencyAverage ( ) { return getCachedValue ( frequencyAverage ) ; } ,
488490 get pitches ( ) { return getCachedValue ( pitches ) ; } ,
0 commit comments