diff options
Diffstat (limited to 'ext/js/display')
| -rw-r--r-- | ext/js/display/display-generator.js | 26 | 
1 files changed, 23 insertions, 3 deletions
| diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 19e88b8a..724bec9c 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -250,10 +250,14 @@ class DisplayGenerator {          node.dataset.readingIsSame = `${reading === expression}`;          node.dataset.frequency = DictionaryDataUtil.getTermFrequency(termTags); -        const pitchAccentCategories = this._getPitchAccentCategories(reading, pronunciations, headwordIndex); +        const {wordClasses} = headword; +        const pitchAccentCategories = this._getPitchAccentCategories(reading, pronunciations, wordClasses, headwordIndex);          if (pitchAccentCategories !== null) {              node.dataset.pitchAccentCategories = pitchAccentCategories;          } +        if (wordClasses.length > 0) { +            node.dataset.wordClasses = wordClasses.join(' '); +        }          this._setTextContent(node.querySelector('.expression-reading'), reading); @@ -762,13 +766,14 @@ class DisplayGenerator {          }      } -    _getPitchAccentCategories(reading, pronunciations, headwordIndex) { +    _getPitchAccentCategories(reading, pronunciations, wordClasses, headwordIndex) {          if (pronunciations.length === 0) { return null; } +        const isVerbOrAdjective = this._isVerbOrAdjective(wordClasses);          const categories = new Set();          for (const pronunciation of pronunciations) {              if (pronunciation.headwordIndex !== headwordIndex) { continue; }              for (const {position} of pronunciation.pitches) { -                const category = this._japaneseUtil.getPitchCategory(reading, position, false); +                const category = this._japaneseUtil.getPitchCategory(reading, position, isVerbOrAdjective);                  if (category !== null) {                      categories.add(category);                  } @@ -776,4 +781,19 @@ class DisplayGenerator {          }          return categories.size > 0 ? [...categories].join(' ') : null;      } + +    _isVerbOrAdjective(wordClasses) { +        for (const wordClass of wordClasses) { +            switch (wordClass) { +                case 'v1': +                case 'v5': +                case 'vs': +                case 'vk': +                case 'vz': +                case 'adj-i': +                    return true; +            } +        } +        return false; +    }  } |