Skip to content

Commit

Permalink
MB-61640: Fuzzy Dynamic Scoring
Browse files Browse the repository at this point in the history
 - Allow edit distances for terms to be read
  • Loading branch information
Likith101 committed Aug 9, 2024
1 parent c2a7075 commit d5ae272
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions automaton.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ func (m *AlwaysMatch) Accept(int, byte) int {

// creating an alwaysMatchAutomaton to avoid unnecessary repeated allocations.
var alwaysMatchAutomaton = &AlwaysMatch{}

type FuzzyAutomaton interface {
Automaton
EditDistance(int) uint8
}
6 changes: 2 additions & 4 deletions fst_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ package vellum

import (
"bytes"

"github.com/blevesearch/vellum/levenshtein"
)

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

cmp := bytes.Compare(i.keysStack, i.nextStart)
if cmp > 0 {
if dfa, ok := i.aut.(*levenshtein.DFA); ok {
i.keysDistance = dfa.EditDistance(autCurr)
if fa, ok := i.aut.(FuzzyAutomaton); ok {
i.keysDistance = fa.EditDistance(autCurr)
}
// in final state greater than start key
return nil
Expand Down

0 comments on commit d5ae272

Please sign in to comment.