You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.go 647B

12345678910111213141516171819202122232425262728293031323334
  1. package snowballstem
  2. import (
  3. "math"
  4. "unicode/utf8"
  5. )
  6. const MaxInt = math.MaxInt32
  7. const MinInt = math.MinInt32
  8. func splitAt(str string, mid int) (string, string) {
  9. return str[:mid], str[mid:]
  10. }
  11. func min(a, b int) int {
  12. if a < b {
  13. return a
  14. }
  15. return b
  16. }
  17. func onCharBoundary(s string, pos int) bool {
  18. if pos <= 0 || pos >= len(s) {
  19. return true
  20. }
  21. return utf8.RuneStart(s[pos])
  22. }
  23. // RuneCountInString is a wrapper around utf8.RuneCountInString
  24. // this allows us to not have to conditionally include
  25. // the utf8 package into some stemmers and not others
  26. func RuneCountInString(str string) int {
  27. return utf8.RuneCountInString(str)
  28. }