diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-07-15 22:39:33 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-15 22:39:33 -0400 | 
| commit | 41fc76d6fd6af9a880ac8b75e7b03afd1395780a (patch) | |
| tree | 902d1d44e83123fdc2fc4eefda9923c9ac500aac /ext/js/language/dictionary-data-util.js | |
| parent | 25d74140ce9843b4bcb86b1b2bbf644602cdb3d0 (diff) | |
Devoice and nasal pronunciation info (#1832)
* Update schema to support information about nasal and devoiced mora
* Expose nasalPositions and devoicePositions in dictionary entry data
* Expose nasalPositions, devoicePositions in grouped pitch info
* Update display generator
* Update test dictionary data
* Update test data
Diffstat (limited to 'ext/js/language/dictionary-data-util.js')
| -rw-r--r-- | ext/js/language/dictionary-data-util.js | 19 | 
1 files changed, 16 insertions, 3 deletions
diff --git a/ext/js/language/dictionary-data-util.js b/ext/js/language/dictionary-data-util.js index 81d1c290..951e10ff 100644 --- a/ext/js/language/dictionary-data-util.js +++ b/ext/js/language/dictionary-data-util.js @@ -108,13 +108,15 @@ class DictionaryDataUtil {                  dictionaryPitchAccentInfoList = [];                  pitchAccentInfoMap.set(dictionary, dictionaryPitchAccentInfoList);              } -            for (const {position, tags} of pitches) { -                let pitchAccentInfo = this._findExistingPitchAccentInfo(reading, position, tags, dictionaryPitchAccentInfoList); +            for (const {position, nasalPositions, devoicePositions, tags} of pitches) { +                let pitchAccentInfo = this._findExistingPitchAccentInfo(reading, position, nasalPositions, devoicePositions, tags, dictionaryPitchAccentInfoList);                  if (pitchAccentInfo === null) {                      pitchAccentInfo = {                          terms: new Set(),                          reading,                          position, +                        nasalPositions, +                        devoicePositions,                          tags,                          exclusiveTerms: [],                          exclusiveReadings: [] @@ -228,11 +230,13 @@ class DictionaryDataUtil {          return results;      } -    static _findExistingPitchAccentInfo(reading, position, tags, pitchAccentInfoList) { +    static _findExistingPitchAccentInfo(reading, position, nasalPositions, devoicePositions, tags, pitchAccentInfoList) {          for (const pitchInfo of pitchAccentInfoList) {              if (                  pitchInfo.reading === reading &&                  pitchInfo.position === position && +                this._areArraysEqual(pitchInfo.nasalPositions, nasalPositions) && +                this._areArraysEqual(pitchInfo.devoicePositions, devoicePositions) &&                  this._areTagListsEqual(pitchInfo.tags, tags)              ) {                  return pitchInfo; @@ -241,6 +245,15 @@ class DictionaryDataUtil {          return null;      } +    static _areArraysEqual(array1, array2) { +        const ii = array1.length; +        if (ii !== array2.length) { return false; } +        for (let i = 0; i < ii; ++i) { +            if (array1[i] !== array2[i]) { return false; } +        } +        return true; +    } +      static _areTagListsEqual(tagList1, tagList2) {          const ii = tagList1.length;          if (tagList2.length !== ii) { return false; }  |