Choose the right algorithm for your use case
masterAlgorithms are categorized by the type of sequence they compare:
- Edit-based: Best for short sequences (e.g., detecting typos).
- Token-based: Best for long sequences (e.g., comparing long texts with modifications).
- Sequence-based: Best for calculating diff sizes between original and changed versions.
Edit-based Algorithm Comparison
| algorithm | substitution | addition | deletion | transposition |
|---|---|---|---|---|
Hamming | ✅ | ❌ | ❌ | ❌ |
Jaro | ❌ | ❌ | ❌ | ✅ |
JaroWinkler | ❌ | ❌ | ❌ | ✅ |
Sift4 | ❌ | ❌ | ❌ | ✅ |
Levenshtein | ✅ | ✅ | ✅ | ❌ |
DamerauLevenshtein | ✅ | ✅ | ✅ | ✅ |
Quick Tips:
- Fastest (Substitutions only):
Hamming. - Fast & Battle-tested:
Jaro. - Fastest (Transpositions):
Sift4. - Comprehensive (No transpositions):
Levenshtein. - Most Comprehensive:
DamerauLevenshtein(but slowest).