diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-09-23 08:46:34 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-09-23 08:46:34 -0700 |
commit | 8d85321cf9a27ee87dfb76c4135aba4b9ae1ddf6 (patch) | |
tree | b07ea066c62d75916eb2b40a4b1de5212a552f35 /ext/bg/js/translator.js | |
parent | 088c608d80ea05c15c6bdf4d043b9b52783f549a (diff) |
update database for new format
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 + }); + } } } |