Skip to content

Commit d5ae272

Browse files
committed
MB-61640: Fuzzy Dynamic Scoring
- Allow edit distances for terms to be read
1 parent c2a7075 commit d5ae272

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

automaton.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,8 @@ func (m *AlwaysMatch) Accept(int, byte) int {
8383

8484
// creating an alwaysMatchAutomaton to avoid unnecessary repeated allocations.
8585
var alwaysMatchAutomaton = &AlwaysMatch{}
86+
87+
type FuzzyAutomaton interface {
88+
Automaton
89+
EditDistance(int) uint8
90+
}

fst_iterator.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ package vellum
1616

1717
import (
1818
"bytes"
19-
20-
"github.com/blevesearch/vellum/levenshtein"
2119
)
2220

2321
// Iterator represents a means of visiting key/value pairs in order.
@@ -219,8 +217,8 @@ OUTER:
219217

220218
cmp := bytes.Compare(i.keysStack, i.nextStart)
221219
if cmp > 0 {
222-
if dfa, ok := i.aut.(*levenshtein.DFA); ok {
223-
i.keysDistance = dfa.EditDistance(autCurr)
220+
if fa, ok := i.aut.(FuzzyAutomaton); ok {
221+
i.keysDistance = fa.EditDistance(autCurr)
224222
}
225223
// in final state greater than start key
226224
return nil

0 commit comments

Comments
 (0)