From 6694a9d9c3a6770ee744310056cadd3567386f3f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 26 Sep 2021 11:08:25 -0400 Subject: [PATCH] Enable frequency dictionaries to specify the frequency mode (#1944) --- ext/data/schemas/dictionary-index-schema.json | 4 ++++ ext/js/language/dictionary-importer.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/data/schemas/dictionary-index-schema.json b/ext/data/schemas/dictionary-index-schema.json index c2f095c7..a8ca0f23 100644 --- a/ext/data/schemas/dictionary-index-schema.json +++ b/ext/data/schemas/dictionary-index-schema.json @@ -46,6 +46,10 @@ "type": "string", "description": "Attribution information for the dictionary data." }, + "frequencyMode": { + "type": "string", + "enum": ["occurrence-based", "rank-based"] + }, "tagMeta": { "type": "object", "description": "Tag information for terms and kanji. This object is obsolete and individual tag files should be used instead.", diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js index 0a10900d..ad5d7a70 100644 --- a/ext/js/language/dictionary-importer.js +++ b/ext/js/language/dictionary-importer.js @@ -201,11 +201,12 @@ class DictionaryImporter { importDate: Date.now() }; - const {author, url, description, attribution} = index; + const {author, url, description, attribution, frequencyMode} = index; if (typeof author === 'string') { summary.author = author; } if (typeof url === 'string') { summary.url = url; } if (typeof description === 'string') { summary.description = description; } if (typeof attribution === 'string') { summary.attribution = attribution; } + if (typeof frequencyMode === 'string') { summary.frequencyMode = frequencyMode; } Object.assign(summary, details);