ML Models & Algorithms
Fuzzy Matching / Fuzzy String Matching
In shortScoring how similar two strings are when they are not identical, to catch typos and variants; it compares characters, not meaning.
Fuzzy matching (or fuzzy string matching) measures how alike two pieces of text are when they are not exactly the same, and turns that into a similarity score. It catches typos, spelling variants and small differences, which makes it ideal for redirect maps, 404 clean-ups and de-duplicating messy data. It works on characters, so it has no understanding of meaning.
How it works
String matching has been studied since at least the 1980s, and methods differ in how they calculate similarity. MLforSEO groups them into five approaches:
- Exact matching, such as the Boyer-Moore algorithm: fast, but one typo and it fails.
- Distance-based matching, such as Levenshtein distance: counts the edits needed to turn one string into the other.
- Phonetic matching, such as Metaphone: matches by sound, useful for names and multilingual data.
- N-gram matching: compares overlapping chunks of characters or words.
- TF-IDF with cosine similarity: weights rarer tokens more heavily so matches are more context-sensitive.
In Python you mostly reach for libraries that bundle these. RapidFuzz is the current default; TheFuzz, the renamed FuzzyWuzzy, now runs on RapidFuzz; and PolyFuzz lets you compare several models side by side.
How it’s used in SEO and marketing
- Redirect mapping during migrations and 404 clean-ups, matching old URLs or titles to the closest live page.
- Competitor metadata analysis, comparing titles to find overlap and gaps.
- Mapping keywords to seed terms or topics as a lightweight first pass.
- Finding misspelled brand mentions and normalising product names or campaign names across platforms.
- Building internal-link shortlists for a human to review.
Example
By raw Levenshtein distance, HARD and HAND are more similar than HARD and HARDER (one substitution versus two insertions), although a human reads HARD and HARDER as far more related. RapidFuzz’s normalised fuzz.ratio disagrees, scoring HARD/HARDER at 80 and HARD/HAND at 75. Neither understands meaning; they just measure spelling differently, which is why you check which scorer your library uses before setting a threshold.
Limitations and things to watch
- No semantics: it is the wrong tool for keyword clustering or judging whether two pages are genuinely related. Use an entity or embedding approach for that.
- Thresholds need calibrating on a sample, and every match list needs human review.
- Comparing every item against every other grows quickly; use whole-matrix functions such as RapidFuzz’s process.cdist for large lists.
- Clean inputs first: lowercase, strip domains and tracking parameters, and compare like with like.
Learn it on MLforSEO
Sources and further reading
Other terms from ML Models & Algorithms
- BERT (Bidirectional Encoder Representations from Transformers)Google's 2018 transformer language model that reads text in both directions to produce context-aware embedding…
- BERTopicA modular topic modelling technique that clusters transformer embeddings and labels each cluster with class-ba…
- BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies)BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies) clusters very large numeric datasets by s…
- BM25A classic ranking function that scores documents by how often query words appear, adjusted for word rarity and…
- Boyer-MooreA fast exact string-search algorithm that compares a pattern from right to left and skips ahead after mismatch…
- c-TF-IDFClass-based TF-IDF: treats each cluster as one document to find the words that best describe it, used by BERTo…
- Centroid-based ClusteringA clustering family that groups data around central points (centroids), each the average of its cluster's memb…
- Convolutional Neural Network (CNN)A deep learning architecture that scans data with small learned filters to detect local patterns; the classic…
- DBSCANDensity-based clustering that groups closely packed points, finds the number of clusters itself and labels iso…