21 lines
331 B
Go
21 lines
331 B
Go
package reader
|
|
|
|
// ORPIndex calculates the approximate optimal recognition
|
|
// point of a word.
|
|
//
|
|
// The returned value is a zero-based rune index.
|
|
func ORPIndex(runes []rune) int {
|
|
length := len(runes)
|
|
|
|
switch {
|
|
case length <= 1:
|
|
return 0
|
|
case length <= 5:
|
|
return 1
|
|
case length <= 9:
|
|
return 2
|
|
default:
|
|
return 3
|
|
}
|
|
}
|