Compare commits

..

2 commits

Author SHA1 Message Date
61bf2009ee Add Trie post
All checks were successful
ci/woodpecker/push/deploy/2 Pipeline was successful
ci/woodpecker/cron/deploy/2 Pipeline was successful
2024-06-30 12:44:50 +01:00
a3747b4f64 posts: trie: add fuzzy matching 2024-06-30 12:44:50 +01:00

View file

@ -161,11 +161,11 @@ def get_fuzzy(self, key: str, max_distance: int = 0) -> Iterator[FuzzyResult[T]]
yield from helper(current_word + c, child, current_row)
# Build the first row -- the edit distance from the empty string
row = list(range(len(key) + 1))
row = list(range(len(word) + 1))
# Base case for the empty string
if (distance := row[-1]) <= max_distance and node._value != None:
yield FuzzyResult(distance, "", node._value)
for c, child in self._children.items():
yield from helper(c, child, row)
yield from helper(c, node, row)
```