github.com/cloudfoundry/cli@v7.1.0+incompatible/cf/util/spellcheck/spellcheck.go (about)

     1  package spellcheck
     2  
     3  import (
     4  	"github.com/sajari/fuzzy"
     5  )
     6  
     7  type CommandSuggester struct {
     8  	model *fuzzy.Model
     9  }
    10  
    11  func (s CommandSuggester) Recommend(cmd string) []string {
    12  	return s.model.Suggestions(cmd, true)
    13  }
    14  
    15  func NewCommandSuggester(existingCmds []string) CommandSuggester {
    16  	model := fuzzy.NewModel()
    17  	model.SetThreshold(1)
    18  	model.SetDepth(1)
    19  
    20  	model.Train(existingCmds)
    21  
    22  	return CommandSuggester{model: model}
    23  }