aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-12 09:59:09 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-12 09:59:09 +0300
commit8d660e282911ffb5d7b504784a3c09f13b164953 (patch)
tree1f6b46ab54ab39d341b82ca701d64842f97da753 /ext/bg/js/dictionary.js
parent6523b77ca13ebbc02cc9a4586a83a9d0ec29807d (diff)
add compact tags
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index ee4f5946..14f90d29 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -110,6 +110,32 @@ function dictTermsUndupe(definitions) {
return definitionsUnique;
}
+function dictTermsCompressTags(definitions) {
+ let lastDictionary = '';
+ 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 filterOutCategories = [];
+
+ if (lastDictionary === dictionary) {
+ filterOutCategories.push('dictionary');
+ } else {
+ lastDictionary = dictionary;
+ }
+
+ if (lastPos === pos) {
+ filterOutCategories.push('pos');
+ } else {
+ lastPos = pos;
+ }
+
+ definition.tags = definition.tags.filter(tag => !filterOutCategories.includes(tag.category));
+ }
+}
+
function dictTermsGroup(definitions, dictionaries) {
const groups = {};
for (const definition of definitions) {