aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-28 13:26:34 -0500
committerGitHub <noreply@github.com>2021-02-28 13:26:34 -0500
commit445f87ebdb01badd5fd62a44bb165e23351e10c6 (patch)
tree80309d706630fc28a7ea5a26dbe4e53b6523d58a /ext/js/display
parentfce2c51709852eea9dc14efe937537383e9c418d (diff)
Get categorization of pitch accents (#1462)
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display-generator.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js
index 32059d86..91dc0862 100644
--- a/ext/js/display/display-generator.js
+++ b/ext/js/display/display-generator.js
@@ -229,7 +229,7 @@ class DisplayGenerator {
// Private
_createTermExpression(details) {
- const {termFrequency, furiganaSegments, expression, reading, termTags} = details;
+ const {termFrequency, furiganaSegments, expression, reading, termTags, pitches} = details;
const searchQueries = [];
if (expression) { searchQueries.push(expression); }
@@ -243,6 +243,11 @@ class DisplayGenerator {
node.dataset.readingIsSame = `${!reading || reading === expression}`;
node.dataset.frequency = termFrequency;
+ const pitchAccentCategories = this._getPitchAccentCategories(pitches);
+ if (pitchAccentCategories !== null) {
+ node.dataset.pitchAccentCategories = pitchAccentCategories;
+ }
+
this._setTextContent(node.querySelector('.expression-reading'), reading.length > 0 ? reading : expression);
this._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this));
@@ -716,4 +721,18 @@ class DisplayGenerator {
node.lang = 'ja';
}
}
+
+ _getPitchAccentCategories(pitches) {
+ if (pitches.length === 0) { return null; }
+ const categories = [];
+ for (const {reading, pitches: pitches2} of pitches) {
+ for (const {position} of pitches2) {
+ const category = this._japaneseUtil.getPitchCategory(reading, position, false);
+ if (category !== null) {
+ categories.push(category);
+ }
+ }
+ }
+ return categories.length > 0 ? categories.join(' ') : null;
+ }
}