When the algorithm is a table

A second word judged by its own share

A spelling checker that offered its commonest nearest word alone when that word's count was many times the next, and two or three words otherwise, beat a coin's mix of one-word and three-word lists by at most two and a half points, and a plain list of two did better. The ratio measures how dominant the first word is, not how likely the second is. Judged instead by its own share of everything within two edits of the misspelling, the second word is shown only when that share is at least 0.15: on short words drawn by use the checker then sits 4.5 points over the coin's line at 1.32 words a query, nearly twice the ratio's lift and above the list of two, and the weight given a two-edit word moves the result by a tenth of a point. A second word with a share under 0.01 is never the source. On misspellings drawn evenly the share is no guide at all, and the list of two wins.

A checker that stops at two edits answers a misspelling with the vocabulary words at the least edit distance from it, two edits at most, and the commonest word at the distance asked which of those words to show when there are several. Showing only the one most used in prose kept 77% of the whole list’s corrections on words of three or four letters, when the misspellings were drawn the way people make them, by how often each word is used; the three commonest kept 96%. A list as long as the doubt tried the list between them: the commonest word alone when its count is at least rr times the next word’s, and the top three otherwise, so the list grows only where the counts are close.

The counts did know when the commonest word was right — it was the source in 36% of queries where it led by a ratio under two and in 91% where it led by over a hundred — yet the ratio was a poor guide to the list’s length. At its best ratio, ten, the checker lay 2.5 points above the coin’s line, the straight line a checker reaches by flipping a weighted coin between showing one word and showing three, and a plain list of two words sat higher, 3.1 points above the same line. On misspellings drawn evenly from the vocabulary, reading the ratio was worse than not.

That essay’s closing section noticed what the ratio measures. It is the first word’s dominance over the second, and the second word’s value does not follow it: a second word with a tenth of the first’s count is worth showing if nothing else is nearby, and worthless if the neighbourhood holds a dozen words more common than it. Under misspellings drawn by use, the chance that a word is the source is its count over the counts of every word the misspelling could have come from, and the walk that found the nearest words has already found those: every vocabulary word within two edits. The proposal was to show the second word whenever its share of that neighbourhood exceeds a threshold, and the third likewise. It predicted about five points over the coin’s line on short words drawn by use, twice the ratio’s lift, failure on the even stream as the ratio had failed, and named the risk: a two-edit word is less likely than a one-edit word by some factor, and a share computed at the wrong factor would be a ratio in disguise.

The neighbourhood, weighted

The vocabulary, the streams and the credit are the earlier essays’. Each answered misspelling has its nearest words, ranked by their counts in prose, and a credit for each list length: one if the source is among the words shown, or the expected share of one when a tie at the list’s end is broken at random. Corrections are counted as a share of all the band’s misspellings, answered or not.

The share of a nearest word is its count over the sum of count times εd\varepsilon^{d} across every vocabulary word within two edits of the misspelling, where dd is how many edits further than the nearest that word lies — nought for the nearest words themselves, one for a word one edit further. The weight ε\varepsilon is how much less likely a typo of one more edit is; the commonest word at the distance found the noisy-channel choice needed it near a hundredth, and 0.1, 0.01 and 0.001 were run. The checker shows the commonest nearest word; the second if its share is at least θ\theta; and the third if the second was shown and its share is at least θ\theta too. The threshold runs from one, where the list is always one word, to nought, where it is the three commonest.

Nearly twice the ratio

On short words drawn by use, showing the second word only when its share of everything within two edits is at least 0.15 lifts the checker 4.5 points above the coin's line between one word and three, at 1.32 words a query — where the ratio rule reached 2.5 and a plain list of two 3.1Words of 3–4 letters on the stream drawn by use, corrections as a share of the band against mean words shown. The share rule at ε = 0.01, thresholds 1, 0.5, 0.3, 0.2, 0.15, 0.1, 0.07, 0.05, 0.03, 0.02, 0.01, 0.005, 0.001, 0: 1 63.8% at 1.00, 0.5 63.8% at 1.00, 0.3 65.8% at 1.06, 0.2 69.0% at 1.19, 0.15 73.4% at 1.32, 0.1 75.5% at 1.46, 0.07 76.7% at 1.54, 0.05 78.1% at 1.67, 0.03 78.8% at 1.76, 0.02 79.3% at 1.80, 0.01 79.7% at 1.87, 0.005 79.7% at 1.92, 0.001 79.7% at 1.96, 0 79.7% at 1.98. The ratio rule (three words in doubt) at its ratios: 1 63.8% at 1.00, 1.25 65.3% at 1.08, 1.5 66.8% at 1.13, 2 68.0% at 1.19, 3 70.4% at 1.32, 5 74.7% at 1.53, 10 76.8% at 1.65, 20 78.8% at 1.80, 50 79.5% at 1.88, 100 79.7% at 1.91, 300 79.7% at 1.97, 1000 79.7% at 1.97, 10000 79.7% at 1.98. Fixed lists: one 63.8% at 1.00, two 76.5% at 1.59, three 79.7% at 1.98.6570758011.251.501.752words shown a querycorrected, % of words of 3–4 lettersone wordtwo wordsthreeshare ruleratio rulecoin's lineε = 0.01up and left is better
Fig. 1 Words of three or four letters drawn by use: corrections against words shown a query, for the share rule at ε = 0.01 and thresholds from 1 to 0, the ratio rule at ratios from 1 to 10,000, the fixed lists of one, two and three words, and the coin’s line from one word to three. The share rule’s best, at θ = 0.15, corrects 73.4% at 1.32 words; the ratio rule’s best lies 2.5 points over the line, the list of two 3.1.

On short words drawn by use, showing the second word only when its share of everything within two edits is at least 0.15 lifts the checker 4.5 points above the coin’s line between one word and three, at 1.32 words a query — where the ratio rule reached 2.5 and a plain list of two 3.1. One word corrects 63.9% of the band at one word a query and three words 79.7% at 1.98. At a threshold of 0.15 the share rule corrects 73.4% and shows a second word on a third of queries; a coin showing one word or three with the same mean length would correct 68.9%. At 0.1 it corrects 75.5% at 1.46 words, 4.3 points above the line. The best point is 1.8 times the ratio rule’s lift, and it is the first rule the essays have measured that beats the list of two, by 1.4 points, while showing about half as many extra words.

The comparison with the list of two can be made without the coin’s line at all. A list of two corrects 76.5% of the band at 1.59 words a query. The share rule at a threshold of 0.07 corrects 76.7% at 1.54 words: the same corrections for five fewer words in a hundred queries. At 0.1 it gives up one point of the list’s corrections, 75.5%, for thirteen fewer words in a hundred. The ratio rule never reached the list of two’s corrections at fewer words than the list shows, which is the earlier essay’s finding put the other way round: a rule that sizes the list must at least beat the rule that does not, and only the share does.

The prediction was five points and twice the ratio. It is 4.5 and 1.8 times: short of both, by about a tenth, and right about the shape. The plate’s share line also differs from the ratio line in a way the lifts do not show. The ratio rule’s points climb slowly from the one-word checker, because the first words it adds are added where the first word barely leads — and in a neighbourhood of many close words a narrow lead still means the source is often the first. The share rule’s first additions, at thresholds of 0.3 and 0.2, are made where the second word is a fifth or more of everything nearby, and every one of them is a query where it was plausible.

What the second word is worth, by its share

Drawn by use, a second word whose share of the neighbourhood is under 0.01 is never the source and one over 0.1 is the source in about 3 queries of ten; drawn evenly, the second word adds more where its share is small than where it is large — 46.2 points a query between 0.03 and 0.1 against 21.8 between 0.1 and 0.2Short words with two or more nearest words, binned by the second commonest word's share of the weighted neighbourhood (ε = 0.01): the queries in each bin and the correction the second word adds, on average, over the commonest alone. Drawn by use: 0–0.01: 32 queries, 0.0 points; 0.01–0.03: 25 queries, 4.0 points; 0.03–0.1: 108 queries, 12.5 points; 0.1–0.2: 127 queries, 30.9 points; 0.2–0.35: 109 queries, 28.9 points; 0.35–1: 14 queries, 28.6 points. Drawn evenly: 0–0.01: 3 queries, 66.7 points; 0.01–0.03: 8 queries, 25.0 points; 0.03–0.1: 39 queries, 46.2 points; 0.1–0.2: 62 queries, 21.8 points; 0.2–0.35: 59 queries, 20.3 points; 0.35–1: 7 queries, 14.3 points.0–0.010.0 · 3266.7 · 30.01–0.034.0 · 2525.0 · 80.03–0.112.5 · 10846.2 · 390.1–0.230.9 · 12721.8 · 620.2–0.3528.9 · 10920.3 · 590.35–128.6 · 1414.3 · 7upper bar: drawn by use · lower: drawn evenly · points added · queriesshareε = 0.01, 3–4 letterssecond word's gain
Fig. 2 Short words with two or more nearest words, binned by the second word’s share of the weighted neighbourhood (ε = 0.01): the points a query the second word adds over the commonest alone, and the queries in each bin. Drawn by use: under 0.01, 0 in 32 queries; 0.01–0.03, 4.0 in 25; 0.03–0.1, 12.5 in 108; 0.1–0.2, 30.9 in 127; 0.2–0.35, 28.9 in 109; over 0.35, 28.6 in 14. Drawn evenly: 66.7 in 3, 25.0 in 8, 46.2 in 39, 21.8 in 62, 20.3 in 59, 14.3 in 7.

Drawn by use, a second word whose share of the neighbourhood is under 0.01 is never the source and one over 0.1 is the source in about three queries of ten; drawn evenly, the second word adds more where its share is small than where it is large — 46.2 points a query between 0.03 and 0.1 against 21.8 between 0.1 and 0.2. The stream drawn by use is the stream on which the share means what it says. Below a share of a hundredth the second word is shown on 32 queries and is the source on none of them. Between 0.03 and 0.1 it is the source an eighth of the time, about what its share would predict once the first word’s own share is counted. From 0.1 up it is the source about three times in ten and the gain stops rising, because a second word’s share can reach a third or more only where the first word’s is not much larger, and the source is then split between them.

That flat top is why the threshold settles near 0.1 to 0.15. Lowering it further adds the queries between 0.03 and 0.1, which are worth an eighth of a correction each — less than the coin’s line pays for a word, which is about a sixth, 15.8 points over 0.98 extra words between one word and three. Raising it removes queries worth three tenths each. The share sorts the queries into those where the second word is cheap at the price and those where it is not, and the ratio could not, because two queries with the same ratio of top counts can have second words with shares a hundredfold apart.

The weight hardly matters

The weight given a two-edit word moves the share rule's best lift by a tenth of a point: 4.6 at ε = 0.1, 4.5 at ε = 0.01, 4.4 at ε = 0.001, all at thresholds of 0.1 or 0.15 — the risk the proposal named, a share computed at the wrong weight, does not arise on short wordsShort words drawn by use: the share rule's lift over the coin's line between one word and three, in points, against the threshold on the second word's share, at ε = 0.1, 0.01, 0.001: ε 0.1: 0.5 0.0, 0.3 0.6, 0.2 1.2, 0.15 3.8, 0.1 4.6, 0.07 4.0, 0.05 3.5, 0.03 3.2, 0.02 3.0, 0.01 2.4, 0.005 1.3, 0.001 0.2; ε 0.01: 0.5 0.0, 0.3 0.9, 0.2 2.1, 0.15 4.5, 0.1 4.3, 0.07 4.0, 0.05 3.4, 0.03 2.7, 0.02 2.4, 0.01 1.8, 0.005 0.9, 0.001 0.2; ε 0.001: 0.5 0.0, 0.3 0.9, 0.2 2.0, 0.15 4.4, 0.1 4.0, 0.07 3.8, 0.05 3.5, 0.03 2.6, 0.02 2.2, 0.01 1.8, 0.005 0.9, 0.001 0.2.024threshold on the second word's sharepoints above the coin's line0.50.20.10.050.020.005ε = 0.1ε = 0.01ε = 0.0013–4 letters, drawn by usepoints above the coin
Fig. 3 Short words drawn by use: the share rule’s lift over the coin’s line against the threshold, at ε = 0.1, 0.01 and 0.001. Best lifts 4.6, 4.5 and 4.4 points, all at thresholds of 0.1 or 0.15; at every threshold the three lines lie within half a point.

The weight given a two-edit word moves the share rule’s best lift by about a tenth of a point — 4.6 at ε = 0.1, 4.5 at 0.01, 4.4 at 0.001, all at thresholds of 0.1 or 0.15 — so the risk the proposal named, a share computed at the wrong weight, does not arise on short words. The reason is in the neighbourhood itself. A misspelling of three or four letters has its nearest words at one edit almost always, and the words one edit further are at two; with ε=0.1\varepsilon = 0.1 they count a tenth, and at 0.001 they count for nothing. What changes between those weights is how much of the neighbourhood’s mass sits outside the nearest words, and the flat lines say that for short words little of it does; that share was not measured on its own.

The noisy-channel choice of the earlier essay was a different decision: which word to put first, comparing a nearer rare word with a farther common one. There the weight decided the answer, since a word a hundred times commoner one edit further wins at ε = 0.1 and only ties at 0.01. Here the first word is chosen by count among the nearest, as before, and the weight only scales the denominator of a share that is compared with a threshold. A factor of a hundred in the weight moves the denominator by a few per cent.

Two streams, two lengths

The share rule is the best of the three wherever misspellings are drawn by use — 4.6 points over the coin on short words and 2.8 on words of five or six letters — and a plain list of two beats it wherever they are drawn evenly, 3.1 against 1.4The best lift over the coin's line between one word and three, in points, of the share rule (best ε and threshold), the ratio rule (best ratio) and a fixed list of two: by use, 3–4 letters: share 4.6, ratio 2.5, two 3.1; by use, 5–6 letters: share 2.8, ratio 2.2, two 1.8; evenly, 3–4 letters: share 1.4, ratio 0.4, two 3.1; evenly, 5–6 letters: share 0.7, ratio 0.0, two 2.0.by use, 3–4 letters4.6 share rule2.5 ratio rule3.1 list of twoby use, 5–6 letters2.8 share rule2.2 ratio rule1.8 list of twoevenly, 3–4 letters1.4 share rule0.4 ratio rule3.1 list of twoevenly, 5–6 letters0.7 share rule0.0 ratio rule2.0 list of twopoints above the coin's linebest setting of each ruletwo streams, two bands
Fig. 4 The best lift over the coin’s line, in points, of the share rule, the ratio rule and a fixed list of two words, on misspellings drawn by use and drawn evenly, of words of three to four letters and five to six. By use: 4.6, 2.5 and 3.1 on short words; 2.8, 2.2 and 1.8 on five or six letters. Evenly: 1.4, 0.4 and 3.1; 0.7, 0 and 2.0.

The share rule is the best of the three wherever misspellings are drawn by use — 4.6 points over the coin on short words and 2.8 on words of five or six letters — and a plain list of two beats it wherever they are drawn evenly, 3.1 against 1.4. On longer words every lift is smaller because the lists are shorter: a misspelling of a six-letter word usually has one nearest word, and a rule about the second word has fewer queries to act on. The order of the rules holds there, the share rule 0.6 points over the ratio and a point over the list of two.

On the even stream the share is not merely weaker; it points the wrong way. The calibration plate shows the second word adding more where its share is small, and the reason is the stream: drawn evenly, the source is as likely to be a rare word as a common one, so a misspelling whose second-nearest word is rare is as likely to have come from it as from anything, and the counts the share is built from describe prose rather than this stream. The counts only short words carry found the same limit for ranking by counts at all: counts are evidence about the source only on a stream whose sources were drawn by them. The prediction expected the share to fail here as the ratio did, and it does, by the same mechanism.

A share against a ratio

The ratio and the share use the same counts, and the difference between them is what they divide by. The ratio divides the first word’s count by the second’s, which compares two words with each other. The share divides the second word’s count by everything nearby, which compares it with all its rivals. A second word with a ratio of five against the first is in a neighbourhood of two if the first is its only rival, and has a share of a sixth; in a neighbourhood of a dozen common words it has a share of a fiftieth. The ratio gives both the same treatment, and the share separates them by a factor of eight.

That is the earlier essay’s question answered in its own terms: the reader’s doubt about a list is a property of everything the misspelling could have been, not of the list’s own words. The answer was already in the walk. A trie fitted to its queries and the triples a typo writes both priced the walk that finds the words within two edits, and the walk returns that neighbourhood whether the checker reads it or not; the share costs one sum over words already found, a few dozen additions a query beside the trie cells the walk itself has to visit to find them.

What the measurement does not say

One vocabulary, one corpus. The counts are one prose corpus’s and the vocabulary its 1,024 commonest words. A larger vocabulary has denser neighbourhoods, where more of the mass sits in words the checker never shows, and the threshold’s best value would fall with it.

A stream drawn by the same counts. The stream drawn by use draws its sources from the same counts the share is computed from, which is the most favourable case possible: the share is then very nearly the source’s probability among the nearest words. Real misspellings are drawn by real use, which the corpus approximates, and the gap between the two is not measured here. A result the size of its own noise is the warning that applies: a lift of 4.5 points over the coin is a few dozen queries out of a few hundred in the band.

Credit, not a reader. A correction is counted when the source is among the words shown. Whether a reader finds the source faster in a list of one, two or three is not measured, and the coin’s line treats each extra word as costing the same.

The third word. The third word is shown only when the second is, and on the same threshold; most of the share rule’s lists are one or two words long, and a separate threshold for the third was not run.

What insurance against an estimate costs priced a decision taken on a count that might be wrong, and the share is a decision of that kind: on the stream drawn by use its count is right, and the decision pays; on the even stream it is wrong, and no threshold rescues it.

Still open: a threshold that reads the stream

The share rule wins on misspellings drawn by use and loses to a plain list of two on misspellings drawn evenly, and a checker does not know which stream it is on. It can find out. A checker that is told which word the reader chose — or which correction was accepted — sees, over many queries, whether the sources it is told about are spread as the counts predict or spread evenly, and one number summarises it: the mean share the counts gave the accepted words. Under use it is high, and the share rule’s threshold is right; under an even stream it is near what a random word among the nearest would get, and a list of two is right.

The measurement that follows feeds the checker its accepted corrections one at a time, keeps that running mean, and switches between the share rule and a list of two when it crosses a midpoint fitted on a separate stream, then charges both streams and a stream that changes from one to the other halfway. The prediction is that on each pure stream it comes within half a point of the better rule after about two hundred accepted corrections, and that on the changing stream it switches within another two hundred. It could fail on the short band’s size: a few hundred answered misspellings a stream may be too few for a running mean to separate the two before the stream is over. The question is whether a checker can learn which of its own statistics to trust from the corrections it is given, or whether the stream must be known before the counts are worth reading.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the concept index makes visible.

The objects this essay names

Each one links to every other essay that touches it.

CorpusEdit distanceExpected costMeasured countPredictionRankingTrieWorkload