Add support for er-hua syllable 'r5' #3

Merged
marvinelsen merged 1 commits from fix-r into main 2024-09-20 13:33:33 +00:00
3 changed files with 9 additions and 1 deletions
Showing only changes of commit 709e267a2d - Show all commits

View File

@ -5,7 +5,7 @@ plugins {
}
group = "com.marvinelsen"
version = "1.1-SNAPSHOT"
version = "1.0.0"
repositories {
mavenCentral()

View File

@ -88,6 +88,10 @@ data class Syllable(
"'$pinyinSyllableWithoutTone is not a valid Pinyin syllable."
}
if (pinyinSyllableWithoutTone == "r" && tone == Tone.FIFTH) {
return pinyinSyllableWithoutTone
}
val sanitizedPinyinSyllableWithoutTone = pinyinSyllableWithoutTone.replace("v", "ü").replace("u:", "ü")
val characterToIndex = sanitizedPinyinSyllableWithoutTone.withIndex().associate { it.value to it.index }

View File

@ -17,6 +17,7 @@ class SyllableTest : ShouldSpec({
"nv3" to Syllable("nv", Tone.THIRD),
"nü3" to Syllable("", Tone.THIRD),
"nu:3" to Syllable("nu:", Tone.THIRD),
"r5" to Syllable("r", Tone.FIFTH),
) { (pinyinWithNumber, expectedSyllable) ->
Syllable.fromPinyinWithToneNumber(pinyinWithNumber) shouldBe expectedSyllable
}
@ -54,6 +55,7 @@ class SyllableTest : ShouldSpec({
Syllable("", Tone.THIRD) to "ㄋㄩˇ",
Syllable("nu:", Tone.THIRD) to "ㄋㄩˇ",
Syllable("nv", Tone.THIRD) to "ㄋㄩˇ",
Syllable("r", Tone.FIFTH) to "˙ㄦ",
) { (syllable, expectedZhuyin) ->
syllable.format(TransliterationSystem.ZHUYIN) shouldBe expectedZhuyin
}
@ -70,6 +72,7 @@ class SyllableTest : ShouldSpec({
Syllable("", Tone.THIRD) to "nü3",
Syllable("nu:", Tone.THIRD) to "nu:3",
Syllable("nv", Tone.THIRD) to "nv3",
Syllable("r", Tone.FIFTH) to "r5",
) { (syllable, expectedPinyinWithToneNumbers) ->
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) shouldBe expectedPinyinWithToneNumbers
}
@ -88,6 +91,7 @@ class SyllableTest : ShouldSpec({
Syllable("", Tone.THIRD) to "nǚ",
Syllable("nu:", Tone.THIRD) to "nǚ",
Syllable("nv", Tone.THIRD) to "nǚ",
Syllable("r", Tone.FIFTH) to "r",
) { (syllable, expectedPinyinWithToneMarks) ->
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_MARKS) shouldBe expectedPinyinWithToneMarks
}