Data quality
One value, fifty spellings: dictionaries, fuzzy matching and human validation
A city typed in capitals, a product with a missing letter, “N/A” where nothing was known: free-text fields multiply the spellings of a few real values, and every analysis built on them inherits the noise. Cleaning them is not about making a machine “understand language”. It is about never letting a resemblance become a false business fact: certain rules first, a key that destroys nothing, similarity as a suggestion only, vetoes, and the last word to someone who knows the business.
The same value, fifty spellings
Open any CRM, claims base or product catalogue and count the ways one value is written: Marseille, MARSEILLE, marseille, Marseile; Dr. Cohen and Dr Cohen; Jérusalem with and without its accent; a supplier name in two alphabets. Each variant becomes its own category, counts are split, rare categories multiply, and a model or a dashboard sees noise where there is one simple fact. Done by hand, the cleaning is long and never finished. Done blindly by an algorithm, it merges things that must never be merged.
Three kinds of knowledge must be kept apart. What is certain: tlv means Tel Aviv because the business says so, and it is applied. What is technical: MARSEILLE, Marseille and marseille differ only by their case, and are made comparable without being rewritten. What is only probable: Marseile is close to Marseille, but no rule says they are the same; the tool only says that the pair deserves a look. The whole method follows that order:
- the raw value, never modified;
- the rules the business already knows, applied once;
- a comparison key that removes what hinders comparison;
- candidate pairs, found fast;
- a precise score for each candidate;
- vetoes on what must never be merged;
- groups around a centre, with the right name;
- the decision of an expert, which becomes the validated dictionary.
Where the usual fuzzy matching goes wrong
The usual recipe fits in three lines: put everything in lower case, remove accents and punctuation, then merge every pair whose similarity passes a threshold chosen by looking at a few examples, pair by pair. We ran it on a simulated column whose truth is known: 10,494 rows, 48 true values written 194 different ways. The values are the look-alikes found in real bases: districts numbered from 1 to 9, contract years, consecutive policy numbers, blood groups, screw sizes such as 2.5 mm and 25 mm, words and their negation such as insured and uninsured, first names that differ by one letter. The noise is the usual one: capitals, missing accents, one slipped key. A false merge is counted each time a group holds one true value more than it should; a missed merge each time a true value is spread over one group more than it should.
- The plain key destroys the meaning before any threshold is chosen. A+ and A− both become a; 2.5 mm becomes 2 5 mm. The blood groups O+ and O−, AB+ and AB− were merged at every threshold, 1.00 included.
- Every threshold trades one error for another. At 0.85: 13 false merges (six consecutive policy numbers made one policy, contract years merged, 2.5 mm with 25 mm) and 16 missed merges. At 0.75: 24 false for 3 missed. At 0.95: 2 false, but 58 spellings left apart from their value. No threshold is right, because the error does not come from the threshold.
- The same column through our engine. With its declared threshold of 0.85, it proposed 42 merges by similarity and 79 spellings that differ only by case, accent or punctuation, all in one review sheet; 102 look-alike pairs were stopped by a veto, and none of them was in truth one value, a design result rather than an independent confirmation: the look-alike families of the simulation are the very cases the vetoes were written and tested for, and its typos never change a digit or a sign nor add two letters to a word, so no true pair could be vetoed. Had every proposal been accepted blindly, there would have been 2 false merges instead of 13: Martin with Martine, Pascal with Pascale, first names that no spelling rule can tell apart, exactly the decision left to the expert. Our engine misses more at the same threshold (22 against 16): it puts precision first. The threshold learned on judged pairs from another column, 0.75, brings the missed merges down to 8 with 3 false merges if everything were accepted, where the usual pass at the same threshold makes 24.
These are counts on one simulated column, with no sampling interval, and the comparison is with the usual automatic pass only: we have not measured a competent standard used correctly, such as a clustering in which a person reviews every proposed group. With an expert who rejects every wrong proposal, our engine ends with 0 false merges and 22 missed merges (8 with the learned threshold); the expert had 6 of its 42 similarity proposals to reject, and the 102 vetoed pairs and the 5 disguised missing values are listed for the expert rather than decided.
Work on distinct values, not on rows
Take, as an illustration rather than a measurement, a base of four million rows holding twelve thousand distinct labels. Everything that follows is computed once per distinct value, with its number of rows, and the decisions are then mapped back onto every row: twelve thousand labels cleaned and compared instead of four million strings. It is faster, and nothing is lost, because the row counts are kept: they are what later decides which spelling becomes the reference.
Step one: the expert’s dictionary, applied once
Everything a person already knows goes into a dictionary: tlv means Tel Aviv, St. means Saint, an internal abbreviation means a product. It is applied once, to whole words, whatever the case, and never in cascade: a rule cannot rewrite the output of another one, so if another rule turns tel into telephone, tlv still becomes Tel Aviv, never Telephone Aviv. Each change is written to a journal, and the dictionary report counts the whole-word replacements actually made, not the values where the letters merely appear inside another word.
Step two: a comparison key that destroys nothing
To compare values, each one gets a key: lower case, accents removed on Latin, Greek and Cyrillic letters only, Hebrew vowel points removed and Hebrew final letters brought to their usual form, punctuation unified. The key is used only to compare; it is never written in place of the value. And some characters are protected because they carry the meaning: numbers with their decimals and their sign, and signs attached to a word. A+ and A− are blood groups, 2.5 mm and 25 mm are two screws, −5 and 5 are two temperatures. These rules are written for each script rather than for “any language”: they are tested on French, English and Hebrew; other scripts keep their marks untouched, and their rules are written and tested before we rely on them.
Step three: find the candidates fast, then score them precisely
Two different questions hide behind “are these two values alike?”. For one given pair, how close are they? The answer is the edit distance , the smallest number of letters to insert, delete or replace to go from one key to the other (Levenshtein), turned into a similarity between 0 and 1, with the number of characters of :
But before that: scoring every pair of twenty thousand distinct values would mean about two hundred million scores, so candidates are found first, roughly and fast. Each key is cut into overlapping fragments of three characters (marseille gives mar, ars, rse and so on, and marseile shares most of them) and becomes a vector whose coordinate for a fragment is its count in the key, tf, times a weight, idf, that grows as the fragment gets rarer among the keys: a fragment found in many keys says little, a rare one says a lot. Two keys whose vectors and point the same way are close,
and only the ten nearest neighbours of each key, with a cosine of at least 0.3, are scored with formula (1). The fragments find the candidates; the edit distance judges them. In our tests, about twenty thousand distinct values take less than half a minute; the score is symmetric, and the result does not depend on the order of the rows.
Step four: what must never be merged
A high similarity is not a proof. Paris 1 and Paris 2 score 0.86, contract 2023 and contract 2024 0.92, two policy numbers 0.91: all different. Employed and unemployed differ by a prefix that reverses the meaning. These pairs are stopped by vetoes before any suggestion: different numbers, different signs, a word that is another one plus a prefix or a suffix, keys too short for a distance to mean anything. They are listed apart, so that the expert can still see them.
Written as one rule: is the multiset of the numbers of the key , each with its sign and its decimals; the multiset of the signs attached to a letter or a digit, as in A+ or C++; its number of characters. A pair is vetoed, , as soon as one of the four conditions holds:
with , and true when the two keys have the same number of words, differ by exactly one, both words made only of letters, and the longer one is the shorter one with at least letters added at its start or at its end. Comparing multisets rather than strings is what keeps 1.5 and 1,5 together (the comma is read as a decimal point) and Paris 1 and Paris 2 apart, whatever their score. A veto is final: no threshold, learned or declared, can bring the pair back among the proposals.
Step five: groups around a centre, and the right name
Linking every similar pair one by one is the classic trap of single linkage: a chain of small differences joins values that share nothing. AAAA, AAAB, AABB, ABBB, BBBB: each one differs from the next by one letter in four, yet the two ends have no letter in common, and the chain would make them one group. Groups are therefore built around centres: values are taken from the most frequent to the rarest, and each one joins the centre it resembles most, if that resemblance passes the threshold, or becomes a centre itself. Every member is close to its own centre, never only to a neighbour.
In symbols: write for the number of rows of the key , summed over all the raw spellings that share it. Keys are taken by decreasing , ties in alphabetical order, never in the order of the rows. When the key comes, is the set of centres already created, and joins
with from formula (1), from formula (3), and ties won by the centre that comes first in alphabetical order; when is empty, becomes a new centre. A member is compared with its centre only, so a chain cannot form.
The name of the group is the most frequent value once the spellings of the same key are summed. Take 40 rows of MARSEILLE, 50 of Marseille, 20 of marseille and 70 of Marseile. Counted spelling by spelling, the typo would win with 70 rows. Summed, the three capitalisations make 110 rows, so the reference is marseille, shown in its most frequent spelling, Marseille.
A worked example, from raw column to decision
The figures below were produced by our tool on a small column, with its default settings.
- Raw column. MARSEILLE (40 rows), Marseille (50), marseille (20), Marseile (70), Marseille 1 (15), Marseille 2 (12), Marseilles (3), N/A (9).
- Keys. The three capitalisations share the key marseille (110 rows); Marseile keeps its own key; N/A is flagged as a disguised missing value and leaves the comparison.
- Candidates and scores. marseille and marseile 0.89, marseille and marseilles 0.90, marseille 1 and marseille 2 0.91.
- Vetoes. marseille 1 and marseille 2, despite 0.91, and every pair where only one side carries a number: the numbers differ, the pairs are kept apart and listed.
- Group. The centre is marseille, with 110 rows, shown as Marseille; marseile and marseilles join it.
- Review sheet. MARSEILLE and marseille → Marseille (same key), Marseile → Marseille (0.89), Marseilles → Marseille (0.90). The expert accepts the typo. Marseilles is the English name of the same city: accepted if the column records places, rejected if it must keep languages apart. That choice belongs to the business, not to the tool.
Step six: the expert decides, and false merges count most
Nothing found by similarity is applied on its own. The suggestions arrive in a review sheet, grouped, with their counts and their score; the expert ticks, corrects or rejects, and only the validated lines are then applied to the data. A long list of variants becomes a much shorter list of decisions, each one taken by someone who knows the business.
Not every error costs the same. A false merge, two different values made one, corrupts the data silently. A missed merge, two spellings of one value left apart, leaves a little visible noise that is easy to fix later. That is also how the result should be judged: not by how many categories disappeared (ten thousand categories reduced to one would be a perfect reduction and a disaster) but by its false merges and missed merges. Once enough pairs have been accepted and rejected, the similarity threshold is learned on them with a score that puts precision first; until there are enough of both, the declared threshold stays in force. Among the pairs with a similarity of at least , counts those the expert judged identical and those judged different; counts the identical pairs left below ; with , precision is deliberately given more weight than recall. That value is a choice of costs, not a mathematical constant: it says that a false merge costs materially more than a missed one. The candidate thresholds are the scores of the judged pairs themselves, and among equally good thresholds the highest, the most prudent, is kept:
On the simulated example, the expert judged 129 candidate pairs of a first column: 109 were one value, 20 were two, just the minimum our engine requires of each kind. Formula (5) gave ; with it would have been 0.71, a threshold that accepts 7 of the 20 different pairs instead of 3. The learned threshold was then applied to a second column of the same simulation, with other values, whose pairs it had never seen: the missed merges fell from 22 to 8, and the review lines the expert had to reject rose from 6 to 10, all of them on first names that differ by one letter and their misspellings. The threshold was chosen without the second column, but both columns share the same families of look-alikes and the same noise: an out-of-sample check within one simulation design, not a confirmation on real data.
When in doubt, the tool proposes less rather than merging wrongly. Values that only pretend to be values, N/A, “unknown”, a dash, are flagged as possible disguised missing values and never proposed as a reference; turning them into missing values remains an explicit decision; filling them is the job of a proper imputation.
What the method deliberately does not do
It does not infer meaning from spelling. Car and automobile, doctor and physician, NYC and New York City look nothing alike letter by letter: only a dictionary entry written by someone who knows can join them. The method handles what spelling can show, typos, case, accents, punctuation, spacing and transliteration variants within one alphabet. Spellings in two alphabets and synonyms are reconciled only when the business declares their equivalence in the expert dictionary.
Two limits show in the measurement. The edit distance counts two swapped letters as two edits, so on a short word one slip weighs heavily: Djion for Dijon scores 0.60. The nine spellings still left apart after the learned threshold all belong to words of five to seven letters. And first names one letter apart, Martin and Martine, are proposed rather than vetoed: no rule on spelling separates them, the expert does.
Why not a language model? A production base needs the same output for the same input, every change traced to a rule or a person and the original value kept; a language model can help an expert on a hard case, not silently rewrite the base.
Not only for insurers
In our health insurance engagement, dictionaries of this kind reconciled the label variants before any reserving model could read the claims. The same work cleans a whole CRM before a campaign, a product catalogue before a price analysis, a supplier list before a spend review, an address base before a geographic study, in French, English or Hebrew. Problems surface early, duplicates, hidden missing values, codes that drifted, while they are still cheap to fix, and the people who know the data spend their time on decisions instead of on sorting. What such checks can find when they are run to the end is told in our article on serendipity through rigour.
References
V. I. Levenshtein (1966), “Binary codes capable of correcting deletions, insertions and reversals”, Soviet Physics Doklady; G. Salton and C. Buckley (1988), “Term-weighting approaches in automatic text retrieval”, Information Processing & Management; C. J. van Rijsbergen (1979), Information Retrieval, 2nd edition, Butterworths; P. Christen (2012), Data Matching: Concepts and Techniques for Record Linkage, Entity Resolution, and Duplicate Detection, Springer.
More publications
PublicationsSerendipity through rigour: the findings nobody was looking for
Domain checks, cross-variable rules, reconciliations and totals split by part: how consistency checks uncovered more than ILS 1 million.
Read the articleData qualityOne column, several populations: finding the real anomalies without flagging a second population
Payments around 100 and around 3,000 in one column: a usual detection flags the second group (55 of 55 values); ours recognises it and flags none.
Read the articleClaims controlClaims leakage analytics: exposure, joins and what should not have been paid
Exposure–claim reconciliation, coverage and limit rules, duplicates and provider outliers, and how to turn leakage flags into recoveries.
Read the articleLet’s build better decisions together
Tell us about the decision you need to make.
A few lines are enough: your sector, the data you have and what you want to improve. We reply personally with a first view of the approach.
- A few lines are enough
- NDA on request
- Code and documentation handed over


