diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-07-26 19:45:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-26 19:45:30 -0400 |
commit | b0596c8a3c6eb7073750ed07ba862b0ba2d44140 (patch) | |
tree | 71df0f7b1a70a7495bc41a28bdf24d4cac4ff5db /ext/js | |
parent | a9710b8acf6370f229098b172eb2a3aa65ae5dc7 (diff) |
Rename pitchAccent in source code (#1852)
* Rename pitchAccentPosition to pitchAccentDownstepPosition
* Rename function
* Rename
* Rename
* pitches => pronunciations
Diffstat (limited to 'ext/js')
-rw-r--r-- | ext/js/data/sandbox/anki-note-data-creator.js | 10 | ||||
-rw-r--r-- | ext/js/display/display-generator.js | 30 | ||||
-rw-r--r-- | ext/js/language/sandbox/dictionary-data-util.js | 38 | ||||
-rw-r--r-- | ext/js/language/sandbox/japanese-util.js | 18 |
4 files changed, 48 insertions, 48 deletions
diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index e09c6d7b..b7abc0c5 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -157,10 +157,10 @@ class AnkiNoteDataCreator { _getPitches(dictionaryEntry) { const results = []; if (dictionaryEntry.type === 'term') { - for (const {dictionary, pitches} of DictionaryDataUtil.getPitchAccentInfos(dictionaryEntry)) { - const pitches2 = []; - for (const {terms, reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} of pitches) { - pitches2.push({ + for (const {dictionary, pronunciations} of DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry)) { + const pitches = []; + for (const {terms, reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} of pronunciations) { + pitches.push({ expressions: terms, reading, position, @@ -171,7 +171,7 @@ class AnkiNoteDataCreator { exclusiveReadings }); } - results.push({dictionary, pitches: pitches2}); + results.push({dictionary, pitches}); } } return results; diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index f6860b93..95b4224b 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -51,14 +51,14 @@ class DisplayGenerator { const headwordsContainer = node.querySelector('.headword-list'); const inflectionsContainer = node.querySelector('.inflection-list'); - const pitchesContainer = node.querySelector('.pronunciation-group-list'); + const groupedPronunciationsContainer = node.querySelector('.pronunciation-group-list'); const frequencyGroupListContainer = node.querySelector('.frequency-group-list'); const definitionsContainer = node.querySelector('.definition-list'); const headwordTagsContainer = node.querySelector('.headword-list-tag-list'); const {headwords, type, inflections, definitions, frequencies, pronunciations} = dictionaryEntry; - const pitches = DictionaryDataUtil.getPitchAccentInfos(dictionaryEntry); - const pitchCount = pitches.reduce((i, v) => i + v.pitches.length, 0); + const groupedPronunciations = DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry); + const pronunciationCount = groupedPronunciations.reduce((i, v) => i + v.pronunciations.length, 0); const groupedFrequencies = DictionaryDataUtil.groupTermFrequencies(dictionaryEntry); const termTags = DictionaryDataUtil.groupTermTags(dictionaryEntry); @@ -72,8 +72,8 @@ class DisplayGenerator { node.dataset.format = type; node.dataset.headwordCount = `${headwords.length}`; node.dataset.definitionCount = `${definitions.length}`; - node.dataset.pronunciationDictionaryCount = `${pitches.length}`; - node.dataset.pronunciationCount = `${pitchCount}`; + node.dataset.pronunciationDictionaryCount = `${groupedPronunciations.length}`; + node.dataset.pronunciationCount = `${pronunciationCount}`; node.dataset.uniqueTermCount = `${uniqueTerms.size}`; node.dataset.uniqueReadingCount = `${uniqueReadings.size}`; node.dataset.frequencyCount = `${frequencies.length}`; @@ -88,7 +88,7 @@ class DisplayGenerator { this._appendMultiple(inflectionsContainer, this._createTermInflection.bind(this), inflections); this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, false); - this._appendMultiple(pitchesContainer, this._createPitches.bind(this), pitches); + this._appendMultiple(groupedPronunciationsContainer, this._createGroupedPronunciation.bind(this), groupedPronunciations); this._appendMultiple(headwordTagsContainer, this._createTermTag.bind(this), termTags, headwords.length); for (const term of uniqueTerms) { @@ -432,19 +432,19 @@ class DisplayGenerator { return this._createTag(this._createTagData(text, 'search')); } - _createPitches(details) { - const {dictionary, pitches} = details; + _createGroupedPronunciation(details) { + const {dictionary, pronunciations} = details; const node = this._templates.instantiate('pronunciation-group'); node.dataset.dictionary = dictionary; - node.dataset.pitchesMulti = 'true'; - node.dataset.pitchesCount = `${pitches.length}`; + node.dataset.pronunciationsMulti = 'true'; + node.dataset.pronunciationsCount = `${pronunciations.length}`; const tag = this._createTag(this._createTagData(dictionary, 'pronunciation-dictionary')); node.querySelector('.pronunciation-group-tag-list').appendChild(tag); let hasTags = false; - for (const {tags} of pitches) { + for (const {tags} of pronunciations) { if (tags.length > 0) { hasTags = true; break; @@ -453,12 +453,12 @@ class DisplayGenerator { const n = node.querySelector('.pronunciation-list'); n.dataset.hasTags = `${hasTags}`; - this._appendMultiple(n, this._createPitch.bind(this), pitches); + this._appendMultiple(n, this._createPronunciation.bind(this), pronunciations); return node; } - _createPitch(details) { + _createPronunciation(details) { const jp = this._japaneseUtil; const {reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = details; const morae = jp.getKanaMorae(reading); @@ -474,7 +474,7 @@ class DisplayGenerator { this._appendMultiple(n, this._createTag.bind(this), tags); n = node.querySelector('.pronunciation-disambiguation-list'); - this._createPitchAccentDisambiguations(n, exclusiveTerms, exclusiveReadings); + this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); n = node.querySelector('.pronunciation-downstep-notation-container'); n.appendChild(this._pronunciationGenerator.createPronunciationDownstepPosition(position)); @@ -488,7 +488,7 @@ class DisplayGenerator { return node; } - _createPitchAccentDisambiguations(container, exclusiveTerms, exclusiveReadings) { + _createPronunciationDisambiguations(container, exclusiveTerms, exclusiveReadings) { const templateName = 'pronunciation-disambiguation'; for (const term of exclusiveTerms) { const node = this._templates.instantiate(templateName); diff --git a/ext/js/language/sandbox/dictionary-data-util.js b/ext/js/language/sandbox/dictionary-data-util.js index 951e10ff..68b15c48 100644 --- a/ext/js/language/sandbox/dictionary-data-util.js +++ b/ext/js/language/sandbox/dictionary-data-util.js @@ -90,7 +90,7 @@ class DictionaryDataUtil { return this._createFrequencyGroupsFromMap(map1); } - static getPitchAccentInfos(dictionaryEntry) { + static getGroupedPronunciations(dictionaryEntry) { const {headwords, pronunciations} = dictionaryEntry; const allTerms = new Set(); @@ -100,18 +100,18 @@ class DictionaryDataUtil { allReadings.add(reading); } - const pitchAccentInfoMap = new Map(); + const groupedPronunciationsMap = new Map(); for (const {headwordIndex, dictionary, pitches} of pronunciations) { const {term, reading} = headwords[headwordIndex]; - let dictionaryPitchAccentInfoList = pitchAccentInfoMap.get(dictionary); - if (typeof dictionaryPitchAccentInfoList === 'undefined') { - dictionaryPitchAccentInfoList = []; - pitchAccentInfoMap.set(dictionary, dictionaryPitchAccentInfoList); + let dictionaryGroupedPronunciationList = groupedPronunciationsMap.get(dictionary); + if (typeof dictionaryGroupedPronunciationList === 'undefined') { + dictionaryGroupedPronunciationList = []; + groupedPronunciationsMap.set(dictionary, dictionaryGroupedPronunciationList); } for (const {position, nasalPositions, devoicePositions, tags} of pitches) { - let pitchAccentInfo = this._findExistingPitchAccentInfo(reading, position, nasalPositions, devoicePositions, tags, dictionaryPitchAccentInfoList); - if (pitchAccentInfo === null) { - pitchAccentInfo = { + let groupedPronunciation = this._findExistingGroupedPronunciation(reading, position, nasalPositions, devoicePositions, tags, dictionaryGroupedPronunciationList); + if (groupedPronunciation === null) { + groupedPronunciation = { terms: new Set(), reading, position, @@ -121,29 +121,29 @@ class DictionaryDataUtil { exclusiveTerms: [], exclusiveReadings: [] }; - dictionaryPitchAccentInfoList.push(pitchAccentInfo); + dictionaryGroupedPronunciationList.push(groupedPronunciation); } - pitchAccentInfo.terms.add(term); + groupedPronunciation.terms.add(term); } } const multipleReadings = (allReadings.size > 1); - for (const dictionaryPitchAccentInfoList of pitchAccentInfoMap.values()) { - for (const pitchAccentInfo of dictionaryPitchAccentInfoList) { - const {terms, reading, exclusiveTerms, exclusiveReadings} = pitchAccentInfo; + for (const dictionaryGroupedPronunciationList of groupedPronunciationsMap.values()) { + for (const groupedPronunciation of dictionaryGroupedPronunciationList) { + const {terms, reading, exclusiveTerms, exclusiveReadings} = groupedPronunciation; if (!this._areSetsEqual(terms, allTerms)) { exclusiveTerms.push(...this._getSetIntersection(terms, allTerms)); } if (multipleReadings) { exclusiveReadings.push(reading); } - pitchAccentInfo.terms = [...terms]; + groupedPronunciation.terms = [...terms]; } } const results2 = []; - for (const [dictionary, pitches] of pitchAccentInfoMap.entries()) { - results2.push({dictionary, pitches}); + for (const [dictionary, pronunciations2] of groupedPronunciationsMap.entries()) { + results2.push({dictionary, pronunciations: pronunciations2}); } return results2; } @@ -230,8 +230,8 @@ class DictionaryDataUtil { return results; } - static _findExistingPitchAccentInfo(reading, position, nasalPositions, devoicePositions, tags, pitchAccentInfoList) { - for (const pitchInfo of pitchAccentInfoList) { + static _findExistingGroupedPronunciation(reading, position, nasalPositions, devoicePositions, tags, groupedPronunciationList) { + for (const pitchInfo of groupedPronunciationList) { if ( pitchInfo.reading === reading && pitchInfo.position === position && diff --git a/ext/js/language/sandbox/japanese-util.js b/ext/js/language/sandbox/japanese-util.js index c7f79751..9257e1e5 100644 --- a/ext/js/language/sandbox/japanese-util.js +++ b/ext/js/language/sandbox/japanese-util.js @@ -239,26 +239,26 @@ const JapaneseUtil = (() => { // Mora functions - isMoraPitchHigh(moraIndex, pitchAccentPosition) { - switch (pitchAccentPosition) { + isMoraPitchHigh(moraIndex, pitchAccentDownstepPosition) { + switch (pitchAccentDownstepPosition) { case 0: return (moraIndex > 0); case 1: return (moraIndex < 1); - default: return (moraIndex > 0 && moraIndex < pitchAccentPosition); + default: return (moraIndex > 0 && moraIndex < pitchAccentDownstepPosition); } } - getPitchCategory(text, pitchAccentPosition, isVerbOrAdjective) { - if (pitchAccentPosition === 0) { + getPitchCategory(text, pitchAccentDownstepPosition, isVerbOrAdjective) { + if (pitchAccentDownstepPosition === 0) { return 'heiban'; } if (isVerbOrAdjective) { - return pitchAccentPosition > 0 ? 'kifuku' : null; + return pitchAccentDownstepPosition > 0 ? 'kifuku' : null; } - if (pitchAccentPosition === 1) { + if (pitchAccentDownstepPosition === 1) { return 'atamadaka'; } - if (pitchAccentPosition > 1) { - return pitchAccentPosition >= this.getKanaMoraCount(text) ? 'odaka' : 'nakadaka'; + if (pitchAccentDownstepPosition > 1) { + return pitchAccentDownstepPosition >= this.getKanaMoraCount(text) ? 'odaka' : 'nakadaka'; } return null; } |