Compare commits

..

2 Commits

Author SHA1 Message Date
5b432776de Merge pull request 'Add support for er-hua syllable 'r5'' (#3) from fix-r into main
All checks were successful
Publish package / publish (push) Successful in 1m34s
Reviewed-on: #3
2024-09-20 13:33:32 +00:00
709e267a2d
Add support for er-hua syllable 'r5'
All checks were successful
Pull Request / build (pull_request) Successful in 2m20s
2024-09-20 15:29:54 +02:00
3 changed files with 9 additions and 1 deletions

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
}