From 2f931e55854daf552f1080ba41b81782000b5e0e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 22 Apr 2020 21:04:18 -0400 Subject: [PATCH 1/2] Fix high pitch calculation --- ext/mixed/js/japanese.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) { From a761e420846c5a60ad70a5ad0df186c26f97ffd1 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 22 Apr 2020 21:37:28 -0400 Subject: [PATCH 2/2] Update tests --- test/test-japanese.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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]