func closestIndex(s []rune, r rune, pos int) int {
	desc := naiveSearchDescending(s, r, pos)
	asc := naiveSearchAscending(s, r, pos)
	da := math.Abs(float64(desc - pos))
	aa := math.Abs(float64(asc - pos))
	if da < aa {
		return desc
	}
	return asc
}
closestIndex returns position of the closest rune r starting
from pos
package jwd
import (
	"bytes"
	"math"
	"strings"
	"unicode/utf8"
)
const weight = 0.1
const commonPrefixLimiter = 4
func sort(s1, s2 string) (shorter, longer string) {
	if utf8.RuneCountInString(s1) < utf8.RuneCountInString(s2) {
		return s1, s2
	}
	return s2, s1
}
func window(s2 string) float64 {
	return math.Floor(float64(utf8.RuneCountInString(s2)/2 - 1))
}
func score(m, t, runes1len, runes2len float64) float64 {
	return (m/runes1len + m/runes2len + (m-math.Floor(t/2))/m) / 3
}
func naiveSearchDescending(s []rune, searched rune, start int) int {
	for i := start; i > 0; i-- {
		if s[i] == searched {
			return i
		}
	}
	return strings.Index(string(s), string(searched))
}
func naiveSearchAscending(s []rune, searched rune, start int) int {
	for i := start; i < len(s); i++ {
		if s[i] == searched {
			return i
		}
	}
	return strings.LastIndex(string(s), string(searched))
}