aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-26 19:45:30 -0400
committerGitHub <noreply@github.com>2021-07-26 19:45:30 -0400
commitb0596c8a3c6eb7073750ed07ba862b0ba2d44140 (patch)
tree71df0f7b1a70a7495bc41a28bdf24d4cac4ff5db /ext/js/language
parenta9710b8acf6370f229098b172eb2a3aa65ae5dc7 (diff)
Rename pitchAccent in source code (#1852)
* Rename pitchAccentPosition to pitchAccentDownstepPosition * Rename function * Rename * Rename * pitches => pronunciations
Diffstat (limited to 'ext/js/language')
-rw-r--r--ext/js/language/sandbox/dictionary-data-util.js38
-rw-r--r--ext/js/language/sandbox/japanese-util.js18
2 files changed, 28 insertions, 28 deletions
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;
}