diff options
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r-- | ext/bg/js/translator.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index ede89fc6..21881cf3 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -141,16 +141,38 @@ class Translator { definition.tags = dictTagsSort(tags); definition.stats = await this.expandStats(definition.stats, definition.dictionary); - definition.frequencies = await this.database.findKanjiFreq(definition.character, titles); + + definition.frequencies = []; + const metas = await this.database.findKanjiMeta(definition.character, titles); + for (const meta of metas) { + if (meta.mode === 'freq') { + definition.frequencies.push({ + character: meta.character, + frequency: meta.data, + dictionary: meta.dictionary + }); + } + } } return definitions; } async buildTermFrequencies(definition, titles) { - definition.frequencies = await this.database.findTermFreq(definition.expression, titles); - if (definition.frequencies.length === 0) { - definition.frequencies = await this.database.findTermFreq(definition.reading, titles); + let metas = await this.database.findTermMeta(definition.expression, titles); + if (metas.length === 0) { + metas = await this.database.findTermMeta(definition.reading, titles); + } + + definition.frequencies = []; + for (const meta of metas) { + if (meta.mode === 'freq') { + definition.frequencies.push({ + expression: meta.expression, + frequency: meta.data, + dictionary: meta.dictionary + }); + } } } |