Merge pull request #472 from toasted-nutbread/fix-pitch-accent-high-calculation

Fix high pitch calculation
This commit is contained in:
toasted-nutbread 2020-04-23 18:27:11 -04:00 committed by GitHub
commit a49e4ccc4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -116,7 +116,11 @@ const jp = (() => {
// Mora functions // Mora functions
function isMoraPitchHigh(moraIndex, pitchAccentPosition) { 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) { function getKanaMorae(text) {

View File

@ -434,17 +434,17 @@ function testIsMoraPitchHigh() {
[[2, 1], false], [[2, 1], false],
[[3, 1], false], [[3, 1], false],
[[0, 2], true], [[0, 2], false],
[[1, 2], true], [[1, 2], true],
[[2, 2], false], [[2, 2], false],
[[3, 2], false], [[3, 2], false],
[[0, 3], true], [[0, 3], false],
[[1, 3], true], [[1, 3], true],
[[2, 3], true], [[2, 3], true],
[[3, 3], false], [[3, 3], false],
[[0, 4], true], [[0, 4], false],
[[1, 4], true], [[1, 4], true],
[[2, 4], true], [[2, 4], true],
[[3, 4], true] [[3, 4], true]