fixing dictionary tags

This commit is contained in:
Alex Yatskov 2017-01-08 11:18:55 -08:00
parent a5efe50322
commit d7b4aa681c
2 changed files with 15 additions and 7 deletions

View File

@ -55,12 +55,7 @@ class Translator {
for (const deinflection of deinflections) { for (const deinflection of deinflections) {
for (const definition of deinflection.definitions) { for (const definition of deinflection.definitions) {
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta)); const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
tags.push(sanitizeTag({ tags.push(buildDictTag(definition.dictionary));
name: definition.dictionary,
category: 'dictionary',
order: 100
}));
definitions.push({ definitions.push({
source: deinflection.source, source: deinflection.source,
reasons: deinflection.reasons, reasons: deinflection.reasons,
@ -96,7 +91,16 @@ class Translator {
} }
} }
return Promise.all(promises).then(sets => this.processKanji(sets.reduce((a, b) => a.concat(b), []))); return Promise.all(promises).then(defSets => {
const definitions = defSets.reduce((a, b) => a.concat(b), []);
for (const definition of definitions) {
const tags = definition.tags.map(tag => buildTag(tag, definition.tagMeta));
tags.push(buildDictTag(definition.dictionary));
definition.tags = sortTags(tags);
}
return definitions;
});
} }
findTermDeinflections(text, dictionaries, cache) { findTermDeinflections(text, dictionaries, cache) {

View File

@ -113,6 +113,10 @@ function undupeTermDefs(definitions) {
return definitionsUnique; return definitionsUnique;
} }
function buildDictTag(name) {
return sanitizeTag({name, category: 'dictionary', order: 100});
}
function buildTag(name, meta) { function buildTag(name, meta) {
const tag = {name}; const tag = {name};
const symbol = name.split(':')[0]; const symbol = name.split(':')[0];