1

Simplify string -> runes conversion

This commit is contained in:
stephenmk 2023-02-03 22:07:41 -06:00
parent 70611a51c4
commit a9d85dc720
No known key found for this signature in database
GPG Key ID: B6DA730DB06235F1

View File

@ -44,10 +44,7 @@ func replaceIterationMarks(text string) string {
// Returns nil if no segmentation is possible. // Returns nil if no segmentation is possible.
func makeKanaSegments(kana string) (segments []string) { func makeKanaSegments(kana string) (segments []string) {
hiragana := replaceIterationMarks(katakanaToHiragana(kana)) hiragana := replaceIterationMarks(katakanaToHiragana(kana))
kanaRunes := []rune{} kanaRunes := []rune(hiragana)
for _, kanaRune := range hiragana {
kanaRunes = append(kanaRunes, kanaRune)
}
kanaRuneCount := len(kanaRunes) kanaRuneCount := len(kanaRunes)
for i := 0; i < kanaRuneCount; i++ { for i := 0; i < kanaRuneCount; i++ {
for j := 0; j < kanaRuneCount-i; j++ { for j := 0; j < kanaRuneCount-i; j++ {