summaryrefslogtreecommitdiff
path: root/ext/js/data
diff options
context:
space:
mode:
authorStefanVukovic99 <stefanvukovic44@gmail.com>2024-01-20 02:25:23 +0100
committerGitHub <noreply@github.com>2024-01-20 01:25:23 +0000
commit2b87c919bcd879c7f356308bc522b95f33e35f3b (patch)
tree1301aa8bf3d9b91ad96bbe9372a66dceba190346 /ext/js/data
parent48f1d012ad5045319d4e492dfbefa39da92817b2 (diff)
Dictionary deinflections (#503)
* wip * wip * fix v3 * wip * fix tests * fix maxitems * hide deinflection definitions * fix anki template * undo unnecessary change * delete console.log * refactor * add set false to handlebars * lint * fix tests * fix comments * fix * use Map in areArraysEqualIgnoreOrder * move inflection source icons to css * lint * improve naming * fix tests * add test * typescript * use for of * wip * comments * anki template upgrade * update descriptions
Diffstat (limited to 'ext/js/data')
-rw-r--r--ext/js/data/options-util.js17
-rw-r--r--ext/js/data/sandbox/anki-note-data-creator.js4
2 files changed, 18 insertions, 3 deletions
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js
index c93e261d..0aabed6f 100644
--- a/ext/js/data/options-util.js
+++ b/ext/js/data/options-util.js
@@ -556,7 +556,8 @@ export class OptionsUtil {
this._updateVersion20,
this._updateVersion21,
this._updateVersion22,
- this._updateVersion23
+ this._updateVersion23,
+ this._updateVersion24
];
if (typeof targetVersion === 'number' && targetVersion < result.length) {
result.splice(targetVersion);
@@ -1156,6 +1157,20 @@ export class OptionsUtil {
}
/**
+ * - Added dictionaries[].useDeinflections.
+ * @type {import('options-util').UpdateFunction}
+ */
+ async _updateVersion24(options) {
+ await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v24.handlebars');
+
+ for (const {options: profileOptions} of options.profiles) {
+ for (const dictionary of profileOptions.dictionaries) {
+ dictionary.useDeinflections = true;
+ }
+ }
+ }
+
+ /**
* @param {string} url
* @returns {Promise<chrome.tabs.Tab>}
*/
diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js
index c0a11869..77d6e357 100644
--- a/ext/js/data/sandbox/anki-note-data-creator.js
+++ b/ext/js/data/sandbox/anki-note-data-creator.js
@@ -376,7 +376,7 @@ export class AnkiNoteDataCreator {
case 'merge': type = 'termMerged'; break;
}
- const {inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry;
+ const {inflectionRuleChainCandidates, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry;
let {url} = context;
if (typeof url !== 'string') { url = ''; }
@@ -401,7 +401,7 @@ export class AnkiNoteDataCreator {
source: (primarySource !== null ? primarySource.transformedText : null),
rawSource: (primarySource !== null ? primarySource.originalText : null),
sourceTerm: (type !== 'termMerged' ? (primarySource !== null ? primarySource.deinflectedText : null) : void 0),
- reasons: inflections,
+ inflectionRuleChainCandidates,
score,
isPrimary: (type === 'term' ? dictionaryEntry.isPrimary : void 0),
get sequence() { return self.getCachedValue(sequence); },