diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 1c2194df..8350e214 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -68,12 +68,11 @@ class Database { const results = []; await this.db.terms.where('expression').equals(term).or('reading').equals(term).each(row => { if (titles.includes(row.dictionary)) { - const tags = row.tags.split('\t'); results.push({ expression: row.expression, reading: row.reading, - tags: dictFieldSplit(tags[0]), - termTags: tags.length > 1 ? dictFieldSplit(tags[1]) : [], + definitionTags: dictFieldSplit(row.definitionTags), + termTags: dictFieldSplit(row.termTags || ''), rules: dictFieldSplit(row.rules), glossary: row.glossary, score: row.score, @@ -95,12 +94,11 @@ class Database { const results = []; await this.db.terms.where('sequence').equals(sequence).each(row => { if (row.dictionary === mainDictionary) { - const tags = row.tags.split('\t'); results.push({ expression: row.expression, reading: row.reading, - tags: dictFieldSplit(tags[0]), - termTags: tags.length > 1 ? dictFieldSplit(tags[1]) : [], + definitionTags: dictFieldSplit(row.definitionTags), + termTags: dictFieldSplit(row.termTags || ''), rules: dictFieldSplit(row.rules), glossary: row.glossary, score: row.score, @@ -229,11 +227,11 @@ class Database { const rows = []; if (summary.version === 1) { - for (const [expression, reading, tags, rules, score, ...glossary] of entries) { + for (const [expression, reading, definitionTags, rules, score, ...glossary] of entries) { rows.push({ expression, reading, - tags, + definitionTags, rules, score, glossary, @@ -241,15 +239,16 @@ class Database { }); } } else { - for (const [expression, reading, tags, rules, score, glossary, sequence] of entries) { + for (const [expression, reading, definitionTags, rules, score, glossary, sequence, termTags] of entries) { rows.push({ expression, reading, - tags, + definitionTags, rules, score, glossary, sequence, + termTags, dictionary: summary.title }); } diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index d057ae83..816e96c4 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -115,8 +115,8 @@ function dictTermsCompressTags(definitions) { let lastPos = ''; for (const definition of definitions) { - const dictionary = JSON.stringify(definition.tags.filter(tag => tag.category === 'dictionary').map(tag => tag.name).sort()); - const pos = JSON.stringify(definition.tags.filter(tag => tag.category === 'pos').map(tag => tag.name).sort()); + const dictionary = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'dictionary').map(tag => tag.name).sort()); + const pos = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'pos').map(tag => tag.name).sort()); const filterOutCategories = []; @@ -133,7 +133,7 @@ function dictTermsCompressTags(definitions) { lastPos = pos; } - definition.tags = definition.tags.filter(tag => !filterOutCategories.includes(tag.category)); + definition.definitionTags = definition.definitionTags.filter(tag => !filterOutCategories.includes(tag.category)); } } @@ -229,7 +229,7 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) { definitionsByGloss[gloss] = { expression: new Set(), reading: new Set(), - tags: new Set(), + definitionTags: new Set(), glossary: definition.glossary, source: result.source, reasons: [], @@ -253,11 +253,11 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) { result.expressions.get(definition.expression).set(definition.reading, new Set()); } - for (const tag of definition.tags) { + for (const tag of definition.definitionTags) { if (typeof tag === 'string') { - definitionsByGloss[gloss].tags.add(tag); + definitionsByGloss[gloss].definitionTags.add(tag); } else if (tag.category && tag.category !== 'dictionary') { - definitionsByGloss[gloss].tags.add(tag.name); + definitionsByGloss[gloss].definitionTags.add(tag.name); } } diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index e8bd43e9..b7b4721e 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -206,14 +206,14 @@ templates['model.html'] = template({"1":function(container,depth0,helpers,partia templates['terms.html'] = template({"1":function(container,depth0,helpers,partials,data) { var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.definitionTags : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.only : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.program(13, data, 0),"data":data})) != null ? stack1 : ""); },"2":function(container,depth0,helpers,partials,data) { var stack1; return "