diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-23 18:27:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 18:27:11 -0400 |
commit | a49e4ccc4e5c7defb30bd88535c18137acf9812c (patch) | |
tree | f6666de47f49aa5ed961ef30a3f79717d348c45f | |
parent | 6b0f1f268b869eed40aa6be9aa43fcfebb9169ed (diff) | |
parent | a761e420846c5a60ad70a5ad0df186c26f97ffd1 (diff) |
Merge pull request #472 from toasted-nutbread/fix-pitch-accent-high-calculation
Fix high pitch calculation
-rw-r--r-- | ext/mixed/js/japanese.js | 6 | ||||
-rw-r--r-- | test/test-japanese.js | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js index 79d69946..ced486dd 100644 --- a/ext/mixed/js/japanese.js +++ b/ext/mixed/js/japanese.js @@ -116,7 +116,11 @@ const jp = (() => { // Mora functions function isMoraPitchHigh(moraIndex, pitchAccentPosition) { - return pitchAccentPosition === 0 ? (moraIndex > 0) : (moraIndex < pitchAccentPosition); + switch (pitchAccentPosition) { + case 0: return (moraIndex > 0); + case 1: return (moraIndex < 1); + default: return (moraIndex > 0 && moraIndex < pitchAccentPosition); + } } function getKanaMorae(text) { diff --git a/test/test-japanese.js b/test/test-japanese.js index 87efdfad..321861d5 100644 --- a/test/test-japanese.js +++ b/test/test-japanese.js @@ -434,17 +434,17 @@ function testIsMoraPitchHigh() { [[2, 1], false], [[3, 1], false], - [[0, 2], true], + [[0, 2], false], [[1, 2], true], [[2, 2], false], [[3, 2], false], - [[0, 3], true], + [[0, 3], false], [[1, 3], true], [[2, 3], true], [[3, 3], false], - [[0, 4], true], + [[0, 4], false], [[1, 4], true], [[2, 4], true], [[3, 4], true] |