Create buildKanjiMeta for parity with buildTermMeta
This commit is contained in:
parent
8233119eb7
commit
a5fc79a754
|
@ -412,26 +412,18 @@ class Translator {
|
||||||
definitions.sort((a, b) => a.index - b.index);
|
definitions.sort((a, b) => a.index - b.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
const kanjiList2 = [];
|
|
||||||
for (const definition of definitions) {
|
for (const definition of definitions) {
|
||||||
kanjiList2.push(definition.character);
|
|
||||||
|
|
||||||
const tags = await this.expandTags(definition.tags, definition.dictionary);
|
const tags = await this.expandTags(definition.tags, definition.dictionary);
|
||||||
tags.push(dictTagBuildSource(definition.dictionary));
|
tags.push(dictTagBuildSource(definition.dictionary));
|
||||||
|
dictTagsSort(tags);
|
||||||
|
|
||||||
definition.tags = dictTagsSort(tags);
|
const stats = await this.expandStats(definition.stats, definition.dictionary);
|
||||||
definition.stats = await this.expandStats(definition.stats, definition.dictionary);
|
|
||||||
definition.frequencies = [];
|
definition.tags = tags;
|
||||||
|
definition.stats = stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
const metas = await this.database.findKanjiMetaBulk(kanjiList2, titles);
|
await this.buildKanjiMeta(definitions, titles);
|
||||||
for (const {character, mode, data, dictionary, index} of metas) {
|
|
||||||
switch (mode) {
|
|
||||||
case 'freq':
|
|
||||||
definitions[index].frequencies.push({character, frequency: data, dictionary});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return definitions;
|
return definitions;
|
||||||
}
|
}
|
||||||
|
@ -482,6 +474,23 @@ class Translator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async buildKanjiMeta(definitions, titles) {
|
||||||
|
const kanjiList = [];
|
||||||
|
for (const definition of definitions) {
|
||||||
|
kanjiList.push(definition.character);
|
||||||
|
definition.frequencies = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const metas = await this.database.findKanjiMetaBulk(kanjiList, titles);
|
||||||
|
for (const {character, mode, data, dictionary, index} of metas) {
|
||||||
|
switch (mode) {
|
||||||
|
case 'freq':
|
||||||
|
definitions[index].frequencies.push({character, frequency: data, dictionary});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async expandTags(names, title) {
|
async expandTags(names, title) {
|
||||||
const tagMetaList = await this.getTagMetaList(names, title);
|
const tagMetaList = await this.getTagMetaList(names, title);
|
||||||
return tagMetaList.map((meta, index) => {
|
return tagMetaList.map((meta, index) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user