From 90f7d5ba07340413aa7e43c3a0cc038690b32db3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 26 Mar 2021 19:50:54 -0400 Subject: Add part of speech info (#1561) * Add part of speech info to headwords * Expose parts of speech to Anki template rendering * Expose parts of speech * Update pitch accent categories * Update docs * Add part-of-speech * Update options and tests * Update markers * Update test data --- ext/js/data/anki-note-data-creator.js | 5 +++-- ext/js/data/options-util.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'ext/js/data') diff --git a/ext/js/data/anki-note-data-creator.js b/ext/js/data/anki-note-data-creator.js index c7047633..fb9c8b8c 100644 --- a/ext/js/data/anki-note-data-creator.js +++ b/ext/js/data/anki-note-data-creator.js @@ -441,7 +441,7 @@ class AnkiNoteDataCreator { const results = []; const {headwords} = dictionaryEntry; for (let i = 0, ii = headwords.length; i < ii; ++i) { - const {term, reading, tags, sources: [{deinflectedText}]} = headwords[i]; + const {term, reading, tags, sources: [{deinflectedText}], wordClasses} = headwords[i]; const termTags = this.createCachedValue(this._convertTags.bind(this, tags)); const frequencies = this.createCachedValue(this._getTermExpressionFrequencies.bind(this, dictionaryEntry, i)); const pitches = this.createCachedValue(this._getTermExpressionPitches.bind(this, dictionaryEntry, i)); @@ -455,7 +455,8 @@ class AnkiNoteDataCreator { get frequencies() { return self.getCachedValue(frequencies); }, get pitches() { return self.getCachedValue(pitches); }, get furiganaSegments() { return self.getCachedValue(furiganaSegments); }, - get termFrequency() { return self.getCachedValue(termFrequency); } + get termFrequency() { return self.getCachedValue(termFrequency); }, + wordClasses }; results.push(item); } diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 334445c6..fd62a558 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -459,7 +459,7 @@ class OptionsUtil { {async: false, update: this._updateVersion7.bind(this)}, {async: true, update: this._updateVersion8.bind(this)}, {async: false, update: this._updateVersion9.bind(this)}, - {async: false, update: this._updateVersion10.bind(this)} + {async: true, update: this._updateVersion10.bind(this)} ]; } @@ -750,9 +750,11 @@ class OptionsUtil { return options; } - _updateVersion10(options) { + async _updateVersion10(options) { // Version 10 changes: // Removed global option useSettingsV2. + // Added part-of-speech field template. + await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v10.handlebars'); delete options.global.useSettingsV2; return options; } -- cgit v1.2.3