Documentation ¶
Index ¶
- type Builder
- type Cell
- func (c Cell) Char() byte
- func (c Cell) Empty() bool
- func (c Cell) Final() (int32, bool)
- func (c *Cell) GobDecode(bs []byte) error
- func (c Cell) GobEncode() ([]byte, error)
- func (c Cell) Next() uint32
- func (c Cell) State() bool
- func (c Cell) String() string
- func (c Cell) Target() uint32
- func (c Cell) Transition() bool
- func (c Cell) Type() CellType
- type CellType
- type DFA
- func (d *DFA) CellAt(s State) Cell
- func (d DFA) Delta(s State, c byte) State
- func (d *DFA) EachCell(f func(Cell))
- func (d *DFA) EachTransition(s State, f func(Cell))
- func (d *DFA) EachUTF8Transition(s State, f func(rune, State))
- func (d *DFA) Final(s State) (int32, bool)
- func (d *DFA) GobDecode(bs []byte) error
- func (d *DFA) GobEncode() ([]byte, error)
- func (d *DFA) Initial() State
- type FinalStateCallback
- type FuzzyDFA
- type FuzzyStack
- type SparseTable
- type State
- type TmpState
- type TmpStateTransition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to build a DFA.
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell represents either a final or non-final state cell or transition cell or an empty cell. Cells are used to repesent either transitions or states in a DFA.
func NewFinalCell ¶
NewFinalCell creates a final cell.
func NewNonFinalCell ¶
NewNonFinalCell creates a non-final cell.
func NewTransitionCell ¶
NewTransitionCell creates a transtion cell
func (Cell) Final ¶
Final returns the asociated data of the cell and true if the cell represent a final state, Otherwise it returns 0, false.
func (Cell) Transition ¶
Transition return true iff the cell represents a transtion.
type CellType ¶
type CellType byte
CellType represents the type of a cell.
There are four types of cells: empty (unused) cells, final state cells, non final state cells and transition cells. Final and non final state cells represent states in the automaton. Transition cells represent transtions between the different states in the automaton.
type DFA ¶
type DFA struct {
// contains filtered or unexported fields
}
DFA is a DFA implementation using a sparse table.
func NewDictionary ¶
NewDictionary builds a minimized sparse table DFA from a list of strings. NewDictionary panics if the build process fails.
func (*DFA) EachTransition ¶
EachTransition iterates over all transitions of the given state calling the callback function f for each transition cell.
func (*DFA) EachUTF8Transition ¶
EachUTF8Transition iterates over all transition of the given state calling the callback function f for each transition. EachUTF8Transition follows UTF8 mutlibyte sequences to ensure that the callback is called for each valid unicode transition.
type FinalStateCallback ¶
FinalStateCallback is a callback function that is called on final states. It is called using the active error, the next position and the data.
type FuzzyDFA ¶
type FuzzyDFA struct {
// contains filtered or unexported fields
}
FuzzyDFA is the basic struct for approximate matching on a DFA.
func NewFuzzyDFA ¶
NewFuzzyDFA create a new FuzzyDFA with a given error limit k and a given DFA
func (*FuzzyDFA) Delta ¶
func (d *FuzzyDFA) Delta(f *FuzzyStack, cb FinalStateCallback) bool
Delta make one transtion on the top of the stack. If a final state is encountered, the callback function is called. It returns false if no more transitions can be done with the active stack.
func (*FuzzyDFA) Initial ¶
func (d *FuzzyDFA) Initial(str string) *FuzzyStack
Initial returns the initial active states of the approximate match for str.
type FuzzyStack ¶
type FuzzyStack struct {
// contains filtered or unexported fields
}
FuzzyStack keeps track of the active states during the apporimxate search.
type SparseTable ¶
type SparseTable struct { Cells []Cell // contains filtered or unexported fields }
SparseTable is a sparse table of cells.
func (*SparseTable) Add ¶
func (t *SparseTable) Add(tmp TmpState) uint32
Add adds a temporary state into the sparse table. It returns the absolute position where the state was inserted. The transitions of the temorary state must b sorted.
type State ¶
type State int
State represents a the state of a DFA. It is a simple integer that points to the active state of the DFA's cell table.
type TmpState ¶
type TmpState struct { Transitions []TmpStateTransition Data int32 Final bool }
TmpState represents a state that should be inerter into a sparse table. It contains a sorted list of
type TmpStateTransition ¶
type TmpStateTransition struct {
// contains filtered or unexported fields
}
TmpStateTransition represent an outgoing transition from a temporary state.
func (TmpStateTransition) String ¶
func (t TmpStateTransition) String() string
String returns a strin representation for a temporary state transition. It is used basically for hashing.