Fix formatting to Pinyin with tone marks for capital vowels
All checks were successful
Pull Request / build (pull_request) Successful in 1m47s
All checks were successful
Pull Request / build (pull_request) Successful in 1m47s
This commit is contained in:
parent
5b432776de
commit
bde4ab9020
@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.marvinelsen"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -88,13 +88,13 @@ data class Syllable(
|
||||
"'$pinyinSyllableWithoutTone is not a valid Pinyin syllable."
|
||||
}
|
||||
|
||||
if (pinyinSyllableWithoutTone == "r" && tone == Tone.FIFTH) {
|
||||
if (pinyinSyllableWithoutTone.lowercase() == "r" && tone == Tone.FIFTH) {
|
||||
return pinyinSyllableWithoutTone
|
||||
}
|
||||
|
||||
val sanitizedPinyinSyllableWithoutTone = pinyinSyllableWithoutTone.replace("v", "ü").replace("u:", "ü")
|
||||
|
||||
val characterToIndex = sanitizedPinyinSyllableWithoutTone.withIndex().associate { it.value to it.index }
|
||||
val characterToIndex = sanitizedPinyinSyllableWithoutTone.lowercase().withIndex().associate { it.value to it.index }
|
||||
val vowelIndex = when {
|
||||
'a' in characterToIndex -> characterToIndex['a']!!
|
||||
'o' in characterToIndex -> characterToIndex['o']!!
|
||||
|
@ -18,6 +18,9 @@ class SyllableTest : ShouldSpec({
|
||||
"nü3" to Syllable("nü", Tone.THIRD),
|
||||
"nu:3" to Syllable("nu:", Tone.THIRD),
|
||||
"r5" to Syllable("r", Tone.FIFTH),
|
||||
"R5" to Syllable("R", Tone.FIFTH),
|
||||
"er2" to Syllable("er", Tone.SECOND),
|
||||
"Er2" to Syllable("Er", Tone.SECOND),
|
||||
) { (pinyinWithNumber, expectedSyllable) ->
|
||||
Syllable.fromPinyinWithToneNumber(pinyinWithNumber) shouldBe expectedSyllable
|
||||
}
|
||||
@ -56,6 +59,9 @@ class SyllableTest : ShouldSpec({
|
||||
Syllable("nu:", Tone.THIRD) to "ㄋㄩˇ",
|
||||
Syllable("nv", Tone.THIRD) to "ㄋㄩˇ",
|
||||
Syllable("r", Tone.FIFTH) to "˙ㄦ",
|
||||
Syllable("R", Tone.FIFTH) to "˙ㄦ",
|
||||
Syllable("er", Tone.SECOND) to "ㄦˊ",
|
||||
Syllable("Er", Tone.SECOND) to "ㄦˊ",
|
||||
) { (syllable, expectedZhuyin) ->
|
||||
syllable.format(TransliterationSystem.ZHUYIN) shouldBe expectedZhuyin
|
||||
}
|
||||
@ -73,6 +79,9 @@ class SyllableTest : ShouldSpec({
|
||||
Syllable("nu:", Tone.THIRD) to "nu:3",
|
||||
Syllable("nv", Tone.THIRD) to "nv3",
|
||||
Syllable("r", Tone.FIFTH) to "r5",
|
||||
Syllable("R", Tone.FIFTH) to "R5",
|
||||
Syllable("er", Tone.SECOND) to "er2",
|
||||
Syllable("Er", Tone.SECOND) to "Er2",
|
||||
) { (syllable, expectedPinyinWithToneNumbers) ->
|
||||
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) shouldBe expectedPinyinWithToneNumbers
|
||||
}
|
||||
@ -92,6 +101,8 @@ class SyllableTest : ShouldSpec({
|
||||
Syllable("nu:", Tone.THIRD) to "nǚ",
|
||||
Syllable("nv", Tone.THIRD) to "nǚ",
|
||||
Syllable("r", Tone.FIFTH) to "r",
|
||||
Syllable("er", Tone.SECOND) to "ér",
|
||||
Syllable("Er", Tone.SECOND) to "Ér",
|
||||
) { (syllable, expectedPinyinWithToneMarks) ->
|
||||
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_MARKS) shouldBe expectedPinyinWithToneMarks
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user