build(deps): bump github.com/blevesearch/bleve/v2 from 2.4.4 to 2.5.0

Bumps [github.com/blevesearch/bleve/v2](https://github.com/blevesearch/bleve) from 2.4.4 to 2.5.0.
- [Release notes](https://github.com/blevesearch/bleve/releases)
- [Commits](https://github.com/blevesearch/bleve/compare/v2.4.4...v2.5.0)

---
updated-dependencies:
- dependency-name: github.com/blevesearch/bleve/v2
  dependency-version: 2.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-04-29 08:41:09 +00:00
committed by GitHub
parent 3d9de26f1c
commit 0c84ba3ad2
254 changed files with 17180 additions and 2192 deletions
+6
View File
@@ -83,3 +83,9 @@ 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
MatchAndDistance(input string) (bool, uint8)
}
+14
View File
@@ -44,6 +44,11 @@ type Iterator interface {
Close() error
}
type FuzzyIterator interface {
Iterator
EditDistance() uint8
}
// FSTIterator is a structure for iterating key/value pairs in this FST in
// lexicographic order. Iterators should be constructed with the FSTIterator
// method on the parent FST structure.
@@ -61,6 +66,8 @@ type FSTIterator struct {
autStatesStack []int
nextStart []byte
editDistance uint8
}
func newIterator(f *FST, startKeyInclusive, endKeyExclusive []byte,
@@ -74,6 +81,10 @@ func newIterator(f *FST, startKeyInclusive, endKeyExclusive []byte,
return rv, nil
}
func (i *FSTIterator) EditDistance() uint8 {
return i.editDistance
}
// Reset resets the Iterator' internal state to allow for iterator
// reuse (e.g. pooling).
func (i *FSTIterator) Reset(f *FST,
@@ -206,6 +217,9 @@ OUTER:
cmp := bytes.Compare(i.keysStack, i.nextStart)
if cmp > 0 {
if fa, ok := i.aut.(FuzzyAutomaton); ok {
i.editDistance = fa.EditDistance(autCurr)
}
// in final state greater than start key
return nil
}
+27 -5
View File
@@ -28,23 +28,45 @@ type DFA struct {
ed uint8
}
/// Returns the initial state
// Returns the initial state
func (d *DFA) initialState() int {
return d.initState
}
/// Returns the Levenshtein distance associated to the
/// current state.
// Returns the Levenshtein distance associated to the
// current state.
func (d *DFA) distance(stateId int) Distance {
return d.distances[stateId]
}
/// Returns the number of states in the `DFA`.
func (d *DFA) EditDistance(stateId int) uint8 {
return d.distances[stateId].distance()
}
func (d *DFA) MatchAndDistance(input string) (bool, uint8) {
currentState := d.Start()
index := 0
// Traverse the DFA while characters can still match
for d.CanMatch(currentState) && index < len(input) {
currentState = d.Accept(currentState, input[index])
if currentState == int(SinkState) {
break
}
index++
}
// Ensure we've processed the entire input and check if the current state is a match
if index == len(input) && d.IsMatch(currentState) {
return true, d.EditDistance(currentState)
}
return false, 0
}
// Returns the number of states in the `DFA`.
func (d *DFA) numStates() int {
return len(d.transitions)
}
/// Returns the destination state reached after consuming a given byte.
// Returns the destination state reached after consuming a given byte.
func (d *DFA) transition(fromState int, b uint8) int {
return int(d.transitions[fromState][b])
}
+11
View File
@@ -117,3 +117,14 @@ func (r *Regexp) Accept(s int, b byte) int {
}
return 0
}
func (r *Regexp) MatchesRegex(input string) bool {
currentState := r.Start()
index := 0
// Traverse the DFA while characters can still match
for r.CanMatch(currentState) && index < len(input) {
currentState = r.Accept(currentState, input[index])
index++
}
return index == len(input) && r.IsMatch(currentState)
}