summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-09-14 10:15:54 -0700
committerAlex Yatskov <alex@foosoft.net>2017-09-14 10:15:54 -0700
commitd3d760ed6c779e03713ef4946a76bf89a4647bcb (patch)
treea245dcca9161ef0b2b542714bcac3107525dd948 /ext/bg/js
parentf5009cd63ccb9e9d9aed3a1d4994c5c8e011f3a4 (diff)
cleanup
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/translator.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 19769536..0cd49c27 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -78,7 +78,7 @@ class Translator {
let definitions = [];
for (const deinflection of deinflections) {
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));
definitions.push({
@@ -136,9 +136,8 @@ class Translator {
}
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));
-
definition.tags = dictTagsSort(tags);
definition.frequencies = await this.database.findKanjiFreq(definition.character, titles);
}
@@ -153,21 +152,22 @@ class Translator {
}
}
- async buildTags(names, title) {
- const results = [];
- for (const name of names) {
- const meta = await this.database.findTagForTitle(name.split(':')[0], title);
+ async expandTags(definition) {
+ const tags = [];
+ for (const name of definition.tags) {
+ 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 || {}) {
if (prop !== 'name') {
- result[prop] = meta[prop];
+ tag[prop] = meta[prop];
}
}
- results.push(dictTagSanitize(result));
+ tags.push(dictTagSanitize(tag));
}
- return results;
+ return tags;
}
}