Fix is valid pinyin method
Some checks failed
Pull Request / build (pull_request) Has been cancelled
Some checks failed
Pull Request / build (pull_request) Has been cancelled
This commit is contained in:
parent
e1dbdb37eb
commit
7c51dd2018
@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.marvinelsen"
|
||||
version = "1.0-SNAPSHOT"
|
||||
version = "1.1-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -15,7 +15,9 @@ data class Syllable(
|
||||
private val zhuyinToneMarkRegex = """[ˊˇˋ˙]""".toRegex()
|
||||
|
||||
fun isValidPinyinWithToneNumberSyllable(pinyinSyllable: String) =
|
||||
pinyinSyllable.last().isDigit() && pinyinSyllable.last().digitToInt() in 1..5 && pinyinSyllable.lowercase() in pinyinToZhuyin
|
||||
pinyinSyllable.last().isDigit() && pinyinSyllable.last().digitToInt() in 1..5 && pinyinSyllable
|
||||
.substring(0, pinyinSyllable.lastIndex)
|
||||
.lowercase() in pinyinToZhuyin
|
||||
|
||||
fun fromPinyinWithToneNumber(pinyinWithToneNumber: String): Syllable {
|
||||
val pinyinWithoutNumber = pinyinWithToneNumber.substring(0, pinyinWithToneNumber.lastIndex)
|
||||
@ -45,7 +47,7 @@ data class Syllable(
|
||||
return Syllable(
|
||||
zhuyinToPinyin[zhuyinWithoutToneMark]!!,
|
||||
Tone.fromZhuyinToneMarkOrNull(zhuyin.last()) ?: Tone.fromZhuyinToneMarkOrNull(zhuyin.first())
|
||||
?: Tone.FIRST
|
||||
?: Tone.FIRST
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user