diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-03-07 20:38:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-07 20:38:40 -0500 |
commit | 643dbfb12a66b98b2fabe82416322f0218474567 (patch) | |
tree | 9746ca8eadd4c8a28d1b72c5ddcc7632feaab9d2 /ext/js/data/anki-note-data.js | |
parent | 19f6bf5a3a669cda311e5a3f162131d8a9823aef (diff) |
Refactor term frequency data (#1503)
* Add getTermFrequency
* Update DisplayGenerator to use getTermFrequency
* Remove termFrequency from Translator data
* Backwards compatibility
* Update tests
Diffstat (limited to 'ext/js/data/anki-note-data.js')
-rw-r--r-- | ext/js/data/anki-note-data.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/js/data/anki-note-data.js b/ext/js/data/anki-note-data.js index 529bad18..a8a82a79 100644 --- a/ext/js/data/anki-note-data.js +++ b/ext/js/data/anki-note-data.js @@ -245,6 +245,7 @@ class AnkiNoteData { } for (const expression of definition2.expressions) { this._defineFuriganaSegments(expression); + this._defineTermFrequency(expression); } } } @@ -257,6 +258,14 @@ class AnkiNoteData { }); } + _defineTermFrequency(object) { + Object.defineProperty(object, 'termFrequency', { + configurable: true, + enumerable: true, + get: this._getTermFrequency.bind(this, object) + }); + } + _getFuriganaSegments(object) { if (this._furiganaSegmentsCache !== null) { const cachedResult = this._furiganaSegmentsCache.get(object); @@ -271,6 +280,11 @@ class AnkiNoteData { return result; } + _getTermFrequency(object) { + const {termTags} = object; + return DictionaryDataUtil.getTermFrequency(termTags); + } + _getAllDefinitions(definition) { const definitions = [definition]; for (let i = 0; i < definitions.length; ++i) { |