Documentation ¶
Index ¶
Constants ¶
const StateLimit = 10000
StateLimit is the maximum number of states allowed
Variables ¶
var ErrTooManyStates = fmt.Errorf("dfa contains more than %d states", StateLimit)
ErrTooManyStates is returned if you attempt to build a Levenshtein automaton which requries too many states.
Functions ¶
This section is empty.
Types ¶
type Levenshtein ¶
type Levenshtein struct {
// contains filtered or unexported fields
}
Levenshtein implements the vellum.Automaton interface for matching terms within the specified Levenshtein edit-distance of the queried term. This automaton recognizes utf-8 encoded bytes and computes the edit distance on the result code-points, not on the raw bytes.
func New ¶
func New(query string, distance int) (*Levenshtein, error)
NewLevenshtein creates a new Levenshtein automaton for the specified query string and edit distance.
func (*Levenshtein) Accept ¶
func (l *Levenshtein) Accept(s int, b byte) int
Accept returns the new state, resulting from the transite byte b when currently in the state s.
func (*Levenshtein) CanMatch ¶
func (l *Levenshtein) CanMatch(s int) bool
CanMatch returns if the specified state can ever transition to a matching state.
func (*Levenshtein) IsMatch ¶
func (l *Levenshtein) IsMatch(s int) bool
IsMatch returns if the specified state is a matching state.
func (*Levenshtein) Start ¶
func (l *Levenshtein) Start() int
Start returns the start state of this automaton.
func (*Levenshtein) WillAlwaysMatch ¶
func (l *Levenshtein) WillAlwaysMatch(s int) bool
WillAlwaysMatch returns if the specified state will always end in a matching state.