cleanup
This commit is contained in:
parent
f5009cd63c
commit
d3d760ed6c
@ -78,7 +78,7 @@ class Translator {
|
|||||||
let definitions = [];
|
let definitions = [];
|
||||||
for (const deinflection of deinflections) {
|
for (const deinflection of deinflections) {
|
||||||
for (const definition of deinflection.definitions) {
|
for (const definition of deinflection.definitions) {
|
||||||
const tags = await this.buildTags(definition.tags, definition.dictionary);
|
const tags = await this.expandTags(definition);
|
||||||
tags.push(dictTagBuildSource(definition.dictionary));
|
tags.push(dictTagBuildSource(definition.dictionary));
|
||||||
|
|
||||||
definitions.push({
|
definitions.push({
|
||||||
@ -136,9 +136,8 @@ class Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const definition of definitions) {
|
for (const definition of definitions) {
|
||||||
const tags = await this.buildTags(definition.tags, definition.dictionary);
|
const tags = await this.expandTags(definition);
|
||||||
tags.push(dictTagBuildSource(definition.dictionary));
|
tags.push(dictTagBuildSource(definition.dictionary));
|
||||||
|
|
||||||
definition.tags = dictTagsSort(tags);
|
definition.tags = dictTagsSort(tags);
|
||||||
definition.frequencies = await this.database.findKanjiFreq(definition.character, titles);
|
definition.frequencies = await this.database.findKanjiFreq(definition.character, titles);
|
||||||
}
|
}
|
||||||
@ -153,21 +152,22 @@ class Translator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async buildTags(names, title) {
|
async expandTags(definition) {
|
||||||
const results = [];
|
const tags = [];
|
||||||
for (const name of names) {
|
for (const name of definition.tags) {
|
||||||
const meta = await this.database.findTagForTitle(name.split(':')[0], title);
|
const base = name.split(':')[0];
|
||||||
|
const meta = await this.database.findTagForTitle(base, definition.dictionary);
|
||||||
|
|
||||||
const result = {name};
|
const tag = {name};
|
||||||
for (const prop in meta || {}) {
|
for (const prop in meta || {}) {
|
||||||
if (prop !== 'name') {
|
if (prop !== 'name') {
|
||||||
result[prop] = meta[prop];
|
tag[prop] = meta[prop];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results.push(dictTagSanitize(result));
|
tags.push(dictTagSanitize(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user