Add support for er-hua syllable 'r5' #3
@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.marvinelsen"
|
group = "com.marvinelsen"
|
||||||
version = "1.1-SNAPSHOT"
|
version = "1.0.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -88,6 +88,10 @@ data class Syllable(
|
|||||||
"'$pinyinSyllableWithoutTone is not a valid Pinyin syllable."
|
"'$pinyinSyllableWithoutTone is not a valid Pinyin syllable."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pinyinSyllableWithoutTone == "r" && tone == Tone.FIFTH) {
|
||||||
|
return pinyinSyllableWithoutTone
|
||||||
|
}
|
||||||
|
|
||||||
val sanitizedPinyinSyllableWithoutTone = pinyinSyllableWithoutTone.replace("v", "ü").replace("u:", "ü")
|
val sanitizedPinyinSyllableWithoutTone = pinyinSyllableWithoutTone.replace("v", "ü").replace("u:", "ü")
|
||||||
|
|
||||||
val characterToIndex = sanitizedPinyinSyllableWithoutTone.withIndex().associate { it.value to it.index }
|
val characterToIndex = sanitizedPinyinSyllableWithoutTone.withIndex().associate { it.value to it.index }
|
||||||
|
@ -17,6 +17,7 @@ class SyllableTest : ShouldSpec({
|
|||||||
"nv3" to Syllable("nv", Tone.THIRD),
|
"nv3" to Syllable("nv", Tone.THIRD),
|
||||||
"nü3" to Syllable("nü", Tone.THIRD),
|
"nü3" to Syllable("nü", Tone.THIRD),
|
||||||
"nu:3" to Syllable("nu:", Tone.THIRD),
|
"nu:3" to Syllable("nu:", Tone.THIRD),
|
||||||
|
"r5" to Syllable("r", Tone.FIFTH),
|
||||||
) { (pinyinWithNumber, expectedSyllable) ->
|
) { (pinyinWithNumber, expectedSyllable) ->
|
||||||
Syllable.fromPinyinWithToneNumber(pinyinWithNumber) shouldBe expectedSyllable
|
Syllable.fromPinyinWithToneNumber(pinyinWithNumber) shouldBe expectedSyllable
|
||||||
}
|
}
|
||||||
@ -54,6 +55,7 @@ class SyllableTest : ShouldSpec({
|
|||||||
Syllable("nü", Tone.THIRD) to "ㄋㄩˇ",
|
Syllable("nü", Tone.THIRD) to "ㄋㄩˇ",
|
||||||
Syllable("nu:", Tone.THIRD) to "ㄋㄩˇ",
|
Syllable("nu:", Tone.THIRD) to "ㄋㄩˇ",
|
||||||
Syllable("nv", Tone.THIRD) to "ㄋㄩˇ",
|
Syllable("nv", Tone.THIRD) to "ㄋㄩˇ",
|
||||||
|
Syllable("r", Tone.FIFTH) to "˙ㄦ",
|
||||||
) { (syllable, expectedZhuyin) ->
|
) { (syllable, expectedZhuyin) ->
|
||||||
syllable.format(TransliterationSystem.ZHUYIN) shouldBe expectedZhuyin
|
syllable.format(TransliterationSystem.ZHUYIN) shouldBe expectedZhuyin
|
||||||
}
|
}
|
||||||
@ -70,6 +72,7 @@ class SyllableTest : ShouldSpec({
|
|||||||
Syllable("nü", Tone.THIRD) to "nü3",
|
Syllable("nü", Tone.THIRD) to "nü3",
|
||||||
Syllable("nu:", Tone.THIRD) to "nu:3",
|
Syllable("nu:", Tone.THIRD) to "nu:3",
|
||||||
Syllable("nv", Tone.THIRD) to "nv3",
|
Syllable("nv", Tone.THIRD) to "nv3",
|
||||||
|
Syllable("r", Tone.FIFTH) to "r5",
|
||||||
) { (syllable, expectedPinyinWithToneNumbers) ->
|
) { (syllable, expectedPinyinWithToneNumbers) ->
|
||||||
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) shouldBe expectedPinyinWithToneNumbers
|
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) shouldBe expectedPinyinWithToneNumbers
|
||||||
}
|
}
|
||||||
@ -88,6 +91,7 @@ class SyllableTest : ShouldSpec({
|
|||||||
Syllable("nü", Tone.THIRD) to "nǚ",
|
Syllable("nü", Tone.THIRD) to "nǚ",
|
||||||
Syllable("nu:", Tone.THIRD) to "nǚ",
|
Syllable("nu:", Tone.THIRD) to "nǚ",
|
||||||
Syllable("nv", Tone.THIRD) to "nǚ",
|
Syllable("nv", Tone.THIRD) to "nǚ",
|
||||||
|
Syllable("r", Tone.FIFTH) to "r",
|
||||||
) { (syllable, expectedPinyinWithToneMarks) ->
|
) { (syllable, expectedPinyinWithToneMarks) ->
|
||||||
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_MARKS) shouldBe expectedPinyinWithToneMarks
|
syllable.format(TransliterationSystem.PINYIN_WITH_TONE_MARKS) shouldBe expectedPinyinWithToneMarks
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user