Add method to test whether a string is a valid pinyin with tone number syllable #1
@ -13,6 +13,9 @@ data class Syllable(
|
||||
private val zhuyinToPinyin = pinyinToZhuyin.entries.associate { it.value to it.key }
|
||||
private val zhuyinToneMarkRegex = """[ˊˇˋ˙]""".toRegex()
|
||||
|
||||
fun isValidPinyinWithToneNumberSyllable(pinyinSyllable: String) =
|
||||
pinyinSyllable.last().isDigit() && pinyinSyllable.last().digitToInt() in 1..5 && pinyinSyllable.lowercase() in pinyinToZhuyin
|
||||
|
||||
fun fromPinyinWithToneNumber(pinyinWithToneNumber: String): Syllable {
|
||||
val pinyinWithoutNumber = pinyinWithToneNumber.substring(0, pinyinWithToneNumber.lastIndex)
|
||||
val lastCharacter = pinyinWithToneNumber.last()
|
||||
|
Loading…
Reference in New Issue
Block a user