Fuzzy matching using Levenshtein distance.
More...
#include <IFilterStrategy.hpp>
|
| | FuzzyMatchStrategy (int maxDistance=2) |
| | Construct fuzzy matcher with max edit distance.
|
| |
| bool | matches (const std::string &value, const std::string &pattern, bool caseSensitive) const override |
| | Match a value against the pattern.
|
| |
| bool | isValidPattern (const std::string &pattern) const override |
| | Validate pattern syntax.
|
| |
| std::string | getName () const override |
| | Get strategy name for serialization/debugging.
|
| |
| std::unique_ptr< IFilterStrategy > | clone () const override |
| | Clone this strategy (for copy semantics)
|
| |
| int | getMaxDistance () const |
| |
|
| static int | levenshteinDistance (const std::string &s1, const std::string &s2) |
| | Calculate Levenshtein distance between two strings.
|
| |
Fuzzy matching using Levenshtein distance.
Matches strings within a specified edit distance. Useful for typo-tolerant filtering.
- Performance:
- Matching: O(n*m) dynamic programming
- Memory: O(min(n,m)) with optimized algorithm
◆ FuzzyMatchStrategy()
| filters::FuzzyMatchStrategy::FuzzyMatchStrategy |
( |
int |
maxDistance = 2 | ) |
|
|
inlineexplicit |
Construct fuzzy matcher with max edit distance.
- Parameters
-
| maxDistance | Maximum Levenshtein distance (default 2) |
◆ clone()
| std::unique_ptr< IFilterStrategy > filters::FuzzyMatchStrategy::clone |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getMaxDistance()
| int filters::FuzzyMatchStrategy::getMaxDistance |
( |
| ) |
const |
|
inline |
◆ getName()
| std::string filters::FuzzyMatchStrategy::getName |
( |
| ) |
const |
|
inlineoverridevirtual |
Get strategy name for serialization/debugging.
- Returns
- Strategy identifier (e.g., "regex", "exact", "fuzzy")
Implements filters::IFilterStrategy.
◆ isValidPattern()
| bool filters::FuzzyMatchStrategy::isValidPattern |
( |
const std::string & |
pattern | ) |
const |
|
inlineoverridevirtual |
Validate pattern syntax.
- Parameters
-
| pattern | The pattern to validate |
- Returns
- true if pattern is valid for this strategy, false otherwise
Used to provide early feedback when constructing filters.
Implements filters::IFilterStrategy.
◆ levenshteinDistance()
| int filters::FuzzyMatchStrategy::levenshteinDistance |
( |
const std::string & |
s1, |
|
|
const std::string & |
s2 |
|
) |
| |
|
staticprivate |
Calculate Levenshtein distance between two strings.
- Parameters
-
| s1 | First string |
| s2 | Second string |
- Returns
- Edit distance (insertions, deletions, substitutions)
◆ matches()
| bool filters::FuzzyMatchStrategy::matches |
( |
const std::string & |
value, |
|
|
const std::string & |
pattern, |
|
|
bool |
caseSensitive |
|
) |
| const |
|
overridevirtual |
Match a value against the pattern.
- Parameters
-
| value | The string to test |
| pattern | The pattern to match against |
| caseSensitive | Whether matching should be case-sensitive |
- Returns
- true if value matches pattern, false otherwise
- Thread Safety:
- Must be thread-safe for concurrent calls.
Implements filters::IFilterStrategy.
◆ m_maxDistance
| int filters::FuzzyMatchStrategy::m_maxDistance |
|
private |
The documentation for this class was generated from the following files: