The Entity Residue: One Decode Pass Leaves 210 of 900 Company Names Unmatched
Decoding feels like a solved chore. A name arrives with a few character references where punctuation should be, a standard unescape routine runs over...
Decoding feels like a solved chore. A name arrives with a few character references where punctuation should be, a standard unescape routine runs over it, and the cleaned value moves on. In this test that routine did exactly what it promised — and still left more than a fifth of the file unmatched against the clean reference set it was supposed to join. The reason was not a faulty routine. It was arithmetic: some of the names had been encoded twice, and one pass of decoding only undoes one layer of encoding. The residue that remained after a single pass was not scattered randomly across the file. It was, almost exactly, one whole group of records, defined entirely by how many times they had been encoded before they arrived.
What The Entity Residue means
The Entity Residue means the set of values that still fail to match their clean counterparts after HTML entity decoding, because they were encoded more times than the number of decode passes applied to them. Each encoding pass replaces characters such as ampersands, quotation marks and apostrophes with character references, and encoding an already encoded value encodes the ampersands inside those references a second time. One decode pass reverses exactly one such layer. A value encoded twice and decoded once is therefore left half-cleaned: readable-looking, improved, and still not equal to the clean string it is supposed to match.
The concept matters because matching is unforgiving in a way that reading is not. A human glancing at a half-decoded name sees a company name with a stray reference in it and understands it perfectly. An exact-match join sees two different strings and reports no match at all. The Entity Residue lives in that gap between human legibility and machine equality: values that look cleaned, in a file whose match rate says otherwise, concentrated in precisely the records that passed through one encoding step too many somewhere upstream.
One pass is exactly one layer
The test file held 900 company name strings, in three groups of 300: clean names with no encoding at all; names encoded once, with characters such as ampersands, quotation marks and apostrophes written as single-layer character references; and names encoded twice, where the references from the first encoding had themselves been encoded again (Source: SmartDataAI import test V6, run 2026-11-23; script and result JSON filed with this batch's evidence pack). Each name was checked by exact match against a clean reference set, under three conditions: no decoding at all, one unescape pass, and two unescape passes.
Before any decoding, exact matching found 480 of 900 names, which is 53.3% (derived from the run counts) (Source: SmartDataAI import test V6, run 2026-11-23; script and result JSON filed with this batch's evidence pack). After one unescape pass, the total rose to 690 of 900, which is 76.7% (derived from the run counts) (Source: SmartDataAI import test V6, run 2026-11-23; script and result JSON filed with this batch's evidence pack). After a second pass, matching reached 900 of 900, which is 100% (Source: SmartDataAI import test V6, run 2026-11-23; script and result JSON filed with this batch's evidence pack). Read as a headline, that is a success story with a slow start: decoding works, and more decoding works better. Read group by group, it is a sharper story about which records each pass actually rescued.
The single-encoded group behaved exactly as intuition suggests. One unescape pass restored it completely, 300 of 300, because one layer of encoding is precisely what one pass removes. The clean group, of course, matched throughout and needed nothing. The double-encoded group behaved differently in a way the headline total conceals. After one pass, only 90 of its 300 names matched — and those 90 were not partially repaired versions of encoded names. They were names that contained no markup-sensitive characters in the first place, such as names carrying only accented letters, so that encoding had never visibly changed them and they looked identical before and after encoding. For those records, the double encoding was real but invisible: there was nothing in the string for either encoding pass to alter.
That detail changes how the residue should be interpreted. After one decode pass, 210 names remained unmatched, and those 210 were the genuinely marked members of the double-encoded group — every name in that group whose characters had actually been transformed. The residue was not a 23.3% random thinning of the file. It was one definable population, sharing one definable history: each of those records had been encoded twice somewhere along its path, and the cleaning pipeline had decoded once. Any downstream analysis that treated matched and unmatched records as equivalent would therefore not be working with a slightly smaller sample of the same population. It would be working with a sample from which one provenance — records that passed through an extra encoding step, plausibly a particular source system, export tool or intermediate store — had been almost entirely removed.
How this was measured
The company names in this test were assembled by a script rather than gathered from any real registry: the script started from clean name strings, left one group untouched, applied one layer of entity encoding to a second group and two layers to a third, so the true encoding depth of every string was known by construction. The script used a fixed seed of 42, making the file identical on every run. Matching and decoding were the script's own deterministic logic — exact string comparison against the clean reference set, and fixed unescape passes — with no randomness and no outside data. This is not a measurement of any commercial product, cleaning tool or matching service, and no such product was tested. The counts are constructed quantities, declared as such: 900 constructed names in three groups of 300, with the headline match shares derived from the run counts and labelled derived wherever they appear (Source: SmartDataAI import test V6, run 2026-11-23; script and result JSON filed with this batch's evidence pack).
Questions, answered
How many decode passes does a double-encoded name need? Two — one for each layer of encoding. In this test the double-encoded group went from partial matching after one pass to full recovery only after the second pass brought the file total to 900 of 900. A single pass restored the single-encoded group completely, 300 of 300, but by construction it can only ever remove one layer.
Why did 90 double-encoded names match after just one pass? Because encoding had never visibly changed them. Those 90 names contained no markup-sensitive characters — names with only accented letters are an example — so their encoded and clean forms were identical strings. They matched under every condition, including no decoding at all, and their presence means 30% of the encoded records (derived, 90 of 300) carry encoding that cannot be detected by looking at them.
Is the residue after one pass a random cross-section of the file? No, and that is the central finding. The 210 names still unmatched after one pass were the visibly marked members of the double-encoded group — one whole population with one shared history. Treating the matched 76.7% (derived) as representative would silently exclude records from whichever source or process encoded its output twice.
Could a pipeline simply decode until the values stop changing? On this file, yes: a second pass reached 100%, and decoding to a stable point is a reasonable strategy. The measurement argues for counting while doing it — recording how many passes were needed and how many values each pass recovered — because that count is evidence about where the file has been, and it is lost if decoding runs silently.
Summary
The Entity Residue is what remains when values encoded twice meet a pipeline that decodes once. In this test, exact matching against a clean reference set rose from 480 of 900 before decoding to 690 of 900 after one unescape pass (both shares derived) and reached 900 of 900 only after a second pass. The single-encoded group recovered fully in one pass; the double-encoded group recovered only in two, apart from 90 names that encoding had never visibly touched. What one pass leaves behind is not random damage. It is a whole group, identifiable, countable, and — until somebody counts it — silently absent from every join.
Sources
- SmartDataAI import test V6 (HTML entity encoding depth), run 2026-11-23; script and result JSON filed with this batch's evidence pack.
- Construction note: the test script (seed fixed at 42) generated every name string and both encoding layers, and applied the matching rules; how the file was built is set out in full in the measurement section.