// Good turing with a linear-combination fallback estimate func JelinekMercer(counts, fallbackCounts gnlp.Counter, fallbackWeight func(key *string) float64, split func(key *string) (string, string)) { counts.Apply(func(key *string, w float64) float64 { _, smaller := split(key) weight := fallbackWeight(key) return (1-weight)*counts.Get(*key) + weight*fallbackCounts.Get(smaller) }) counts.Normalize() }