Files
fast_reader/internal/reader/orp.go

21 lines
331 B
Go
Raw Normal View History

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
}
}