ML Models & Algorithms
Distance-based matching
In shortFuzzy string matching that scores how many character edits separate two strings, so near matches with typos or small spelling changes can be found.
Distance-based matching is a family of fuzzy matching methods that measure how far apart two strings are by counting the edits needed to turn one into the other. The fewer edits, the closer the match. It is the go-to approach when the same thing is written in slightly different ways, such as typos, plurals or small URL changes.
How it works
The core idea is edit distance: the minimum number of operations needed to convert one string into another. The main variants differ in which operations they allow:
- Levenshtein distance counts insertions, deletions and substitutions.
- Damerau-Levenshtein also counts swapping two neighbouring letters as one edit.
- Jaro and Jaro-Winkler score shared characters and transpositions; Jaro-Winkler rewards strings that start the same way, which is why it is popular for names.
Most SEO scripts use a normalised similarity score from 0 to 100 instead of the raw distance. Libraries such as RapidFuzz and TheFuzz compute these scores quickly and offer variants that ignore word order or compare the best-matching part of a longer string.
How it’s used in SEO and marketing
- 404 and redirect mapping. Match broken or old URLs to the closest live URL during migrations.
- Keyword variants. Group misspellings and near-duplicates in a keyword list.
- Metadata checks. Compare your titles with competitors’ to find near-identical phrasing.
- Data cleaning. Deduplicate product names, author names or company names across exports.
Example
MLforSEO’s fuzzy matching guide uses HARD, HAND and HARDER. By raw Levenshtein distance, HARD and HAND are closer (one substitution) than HARD and HARDER (two insertions). But the normalised ratio in RapidFuzz and FuzzyWuzzy is built on insertions and deletions only, and it rates HARD/HARDER at 80 and HARD/HAND at 75. Neither score understands meaning; they simply measure spelling differently. Always check which score your library returns before setting a threshold.
Limitations and things to watch
- It ignores meaning: “cheap flights” and “budget airfare” score as very different. Use embeddings or Sentence-BERT when meaning matters.
- Short strings swing wildly, since one edit is a large share of a short word.
- Comparing every string with every other string gets slow on large lists, so use vectorised functions or narrow the candidates first.
- Thresholds need tuning on a hand-checked sample.
Learn it on MLforSEO
Where Distance-based matching shows up on MLforSEO
Learn it in a course
Read about it on the blog
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…
