Moses Rules
A translation system needs a consistent way to handle punctuation without breaking abbreviations and other language-specific forms. Moses tokenization combines general splitting rules with exceptions for those cases.
14 sections · 15 questions · 4 coding challenges
The arrow keys move between sections too.
How Could a Translation System Compare Text Consistently?
BOTIE
Moses, presented in 2007 as an open-source statistical machine translation toolkit, came with practical text-processing tools. Its tokenizer applied punctuation rules and language-specific conventions so that training and translation could use compatible units.
The idea is to make boundary decisions explicit and repeatable. Separate punctuation where the rules require it, preserve recognised exceptions, and use the same preparation for later inputs. These decisions affect the counts and alignments a translation model learns. Moses-style tokenisation is consequently a particular collection of conventions, not a guarantee that all languages or all punctuation can be handled identically.
A Full Stop Does Not Always End a Sentence
A translation system can read a sentence as pieces and later produce another sequence of pieces. Those outputs must be assembled into readable text.
Moses-style rules consider punctuation, escaping, and reconstruction as part of a processing pipeline rather than treating tokenization as the final output.
Separate processing units from displayed text
The translation model may need punctuation as separate units even though a reader expects it attached in ordinary writing. The internal representation and final display serve different purposes.
Readable text
- Hello, world!
The input and output conventions belong together
The detailed examples inspect token boundaries, spans, escaping, and detokenization behaviour.
This SDK implements a stated subset of conventions. Its actual results, rather than the family name alone, define its contract.
Explore the full example
Compare a sentence-ending period, an abbreviation, and a decimal. Inspect which rule applies and where an exception list changes the cut.
…
Part 1. Rules Written for a Translation System
1. The pieces have to go back together again
The three rules on the pages before this one were each answering a question and none of them was asked what happened next. Splitting on spaces asks where the gaps are, the boundary rules ask which pairs of characters a word may break between, and the annotation rules ask which units a person marking up grammar needs a row for. Every one of those ends when the pieces come out.
These rules were written by somebody with the pieces coming out of one end of a system and going back in at the other. A translation system was trained on pieces, decoded into pieces, and then had to hand a reader a sentence, so whatever was done on the way in had to be undoable on the way out. We carry the same sentence the other pages carry, because it breaks in the three places that matter here.
Dr. Alvarez didn't expect the low-cost re-analysis.Read it as somebody building a phrase table. The stop after Dr has to stay, because Dr. and Dr would otherwise be two rows for one title. The stop at the end has to come off, for the same reason from the other side, since re-analysis. and re-analysis are one word written twice. And the apostrophe in didn’t hides a negation that the target language will spell as a word of its own, so it has to be visible to whatever aligns the two sides.
Keep in mind
2. The running sentence, cut, with every span
Here is the whole method applied once. Nine pieces, each shown with the half-open span of the sentence it stands for, so the first number is where it starts and the second is one past where it stops.
Nine pieces, and where each came from
Dr. [0, 3)
Alvarez [4, 11)
didn [12, 16)
't [16, 18)
expect [19, 25)
the [26, 29)
low-cost [30, 38)
re-analysis [39, 50)
. [50, 51)Four things happened. The contraction was cut at the apostrophe, at a position where there is no space. The final stop came off and became a piece of its own. The stop after Dr did not, so the abbreviation survived whole. And both hyphenated compounds were left exactly as they were written.
Read the spans down the right-hand side and they run continuously through the sentence, skipping only the six spaces. Every piece is the slice of the sentence its two numbers name, character for character, and unlike the previous page that remains true in every part of this one.
Keep in mind
3. Nine pieces twice over, and seven of them the same
The annotation rules give nine pieces on that sentence too, which is why the two are so often taken for one method. They are not the same nine. Seven of the pieces are shared, and the two that are not are the halves of the contraction.
| rule | pieces | what it did to the contraction |
|---|---|---|
| every run of spaces | 7 | left it whole, along with both stops |
| the annotation rules | 9 | cut it into did and n't, in front of the negation |
| these rules | 9 | cut it into didn and 't, at the apostrophe |
| a table of exceptions | 13 | cut in front of the negation, and both compounds cut at the hyphen as well |
Four answers to one sentence. The two nines share seven pieces, and the two that differ are exactly the two halves of the contraction.
The cut in front of the n is a claim about English, that the negation is a morpheme spelt n’t. The cut at the apostrophe is a claim about nothing at all; it is one rule applied wherever an apostrophe stands between two letters, with no list and no exception. Both give back the sentence when the pieces are joined, so reversibility does not choose between them. What chose was that the second needs nothing known about English to state, and the same script had to run over eleven languages of proceedings while the first would have needed a linguist for each of them.
Keep in mind
4. What the rules read, and what they do not
It is worth being exact about how little there is here. The whole method is one pass over each run of characters that has no spacing in it, followed by a second pass that settles the final stop, and the questions asked are these.
| the question | what is consulted to answer it |
|---|---|
| is this character a piece on its own | whether it is a letter, a digit, a stop, an apostrophe or a hyphen. Anything else stands alone wherever it is, one character at a time, with one exception for a comma that has a digit on both sides of it. |
| which side does this apostrophe go with | the character before it and the character after it, plus the setting that says which language is being read. Nothing else, and no list of forms. |
| does this final stop belong to the word | whether there is another stop and a letter inside the word, whether the word is on a named list, and the first character of the next word. This is the only clause anywhere here that reads a list. |
There is no dictionary of English, no frequency count and nothing learned from a corpus. Two switches sit beside the clauses and are off unless a caller asks, one that cuts a compound at its hyphen and leaves a marker where the hyphen was, and one that rewrites a handful of characters a file format would otherwise swallow. Both are in Part 4, because both are rewritings and both are undoable, which is the argument of that part.
Keep in mind
Part 2. The Full Stop, and the List It Cannot Do Without
5. One character doing two jobs
A full stop marks the end of a sentence and it marks an abbreviation, and it is the same character both times. In our running sentence both jobs are being done, once after Dr and once at the end, and a rule that cuts every stop off gets the second right and the first wrong while a rule that cuts none off does the reverse.
The annotation rules settle this with a fact about their pipeline rather than about English. They ran on one sentence at a time, so the last stop in the text is the sentence’s and every other stop belongs to whatever it is touching. That is exact when the text really is one sentence and it is not a claim about words at all.
These rules could not use it. Proceedings arrive as paragraphs, the sentence boundaries were another problem entirely, and the same script had to run over eleven languages of them. So the clause here asks about the word instead, and asking about the word is where a list becomes unavoidable, because Dr. and away. are the same shape. Nothing in the characters separates a title from an ordinary word with a stop after it.
Keep in mind
6. Four clauses, and only one of them is a list
A word ending in exactly one stop keeps that stop when any of four things is true, and the list is only the second of them. Read them as four separate attempts to recognise an abbreviation, of which three cost nothing to state.
the part before the stop holds another stop and a letter
U.S. e.g. i.e.
the part before the stop is on the named list
Dr. Prof. Ltd. Nov. J.
the part before the stop is on the figures list and a figure follows
No. 5 Art. 3
the next word begins with a lowercase letter
et al. ran approx. fortyThe first clause catches every initialism at once and needs no vocabulary, since a word with an interior stop and a letter in it is not an ordinary English word. The fourth is the interesting one, and it is a piece of reasoning about writing rather than about language, that an English sentence begins with a capital, so a lowercase word after a stop means the stop did not end a sentence. It costs one character of lookahead and it rescues abbreviations that nobody ever listed.
The third clause exists because No. is an abbreviation in No. 5 and an ordinary word in No. Nothing arrived. Those two are the same five characters and the difference is entirely in what comes next, so the entry carries a condition rather than an unconditional promise.
Keep in mind
7. The same stop, kept in one text and split in another
The way to see those clauses working is to give the rules the same abbreviation twice with different writing after it. Ten stops are below, every one of them somewhere in the middle of its text rather than at the end, so every one of them has an answer that can be stated before any rule is run.
…
Read the three pairs. No. keeps its stop before a figure and loses it before a sentence, which is the third clause doing exactly what it was written for. approx. is on no list at all and keeps its stop before forty and loses it before 40, which is the fourth clause rescuing a word nobody thought of and then failing on the same word for a reason that has nothing to do with the word. And et al. survives before a lowercase verb and is cut in front of a capital.
Keep in mind
8. Scored against an answer written down first
Those ten stops can be scored, since each of them has a right answer. Eight belong to the word in front of them and two end a sentence. These rules place seven of the ten where they belong, the annotation rules place eight, and a written-out table of exceptions places four.
The middle number is the one to be careful with. The annotation rules answered kept on all ten, because none of the ten stops is the last character of its text and their clause keeps every stop that is not. So their eight is exactly the number of cases whose answer happens to be kept, reached without distinguishing anything, and a set of ten with the proportions reversed would have given them two. These rules answered kept five times and split five times, so their seven is a score a differently balanced set would not move nearly so far.
| over the same ten stops | these rules | the annotation rules | a table of exceptions |
|---|---|---|---|
| placed where it belongs | 7 | 8 | 4 |
| answered kept | 5 | 10 | 2 |
| stops whose answer is kept | 8 | 8 | 8 |
A rule with no discrimination at all scores the number in the third row. Only the first column comes from a rule that answered both ways.
Keep in mind
9. An abbreviation nobody listed
All three of the misses above are the same failure. Gov. is a title and is not on the list, and the word after it is a surname beginning with a capital, so no clause saves it and the rules answer Gov and a stop. The annotation rules keep it whole, and they are right by accident, since they would keep small. whole in the same position.
Gov. Reyes asked for the figures.
-> Gov . Reyes asked for the figures .
Dr. Alvarez signed the re-analysis.
-> Dr. Alvarez signed the re-analysis .Two titles, written identically, one on the list and one not, and the difference in the output is a spurious piece and a spurious row. That is the exact failure the whole method was built to prevent, since Gov now sits in the table beside every other truncated word and the stop it lost sits beside every sentence-final stop.
›Why a longer list does not close this
The obvious repair is more entries, and it helps, in the sense that any particular missing word can be added. What it cannot do is change the shape of the answer. A word the clauses examined and left whole and a word no clause covers come back looking the same, so a caller receives Gov and a stop with nothing anywhere reporting that a list was consulted and found nothing. Adding Gov leaves Sen, and adding that leaves the next one, and the writing gives no signal that would let a rule notice it has met one.
Keep in mind
10. Fifty-five entries, and how many a corpus reaches
A list that carries a method and a list nobody hits are different objects, so it is worth counting. The English list here holds 55 entries, of which 27 are named words, 26 are the single capitals that catch an initial in a name, and 2 keep their stop only when a figure follows.
Counting over the six-sentence notebook would say nothing, since it holds one abbreviation, so the corpus below is eighteen sentences of minuted proceedings written for this page, with titles, months, article numbers and company suffixes in them. It is the register the rules were made for and it is deliberately generous to them.
…
The question the list answers was asked 39 times over those eighteen sentences, which is how many runs of characters ended in exactly one stop, and 19 entries answered it. The other 36 were never consulted at all, so a third of the list is doing every piece of the work it does here and the remaining two-thirds is there for writing this corpus does not contain. Five real abbreviations turn up that no entry covers, which is five more than the unused entries would suggest.
The table in the middle of the panel is the finding I did not expect, and it corrects what section 6 implies. Twenty stops were kept over these eighteen sentences, 18 of them by the named list and 2 by the figures list, and the two clauses that read characters kept none at all. The interior-stop clause needs a word like U.S., which these sentences happen not to contain, and the lowercase clause needs an abbreviation followed by an ordinary lowercase word, which in eighteen separate sentences almost never happens because the abbreviations here are titles and the next word is a surname.
Keep in mind
Check yourself
Questions on Parts 1 and 2
Question 1 of 5
Both rule lists give nine pieces on the running sentence and part on the contraction, one cutting in front of the n and the other at the apostrophe. What decided it here?
Part 3. A Rule Everywhere, and a Named List of Places It Must Not
11. The shape, and why it is not simply a longer rule
Step back from the full stop for a moment, because the clause that reads a list has a shape that turns up all over this section of the site and is worth naming once. A rule states what to do everywhere, a table names the places where the rule must not be followed, and the table is consulted first.
for each run of characters with no spacing in it
if the run is named in the table
do what the table says and stop
otherwise
apply the rulesThe reason it is not a longer rule is that the exceptions are not describable as characters. A rule that ends a word before n’t produces ca from can’t, which is wanted, and would produce wo from won’t and sha from shan’t, and any attempt to fix one of those inside the pattern breaks the others. As a table it is one line each, checked before the pattern runs, and the pattern is untouched.
The same argument runs the other way for an abbreviation. Mr. is a capital, two lowercase letters and a stop, which is precisely the shape of Ran., so no reading of the characters keeps one and cuts the other. A named list is what is left over when the writing genuinely does not carry the distinction, and reaching for one is a report that the characters have been examined and found silent rather than a shortcut past a rule somebody could have written.
Keep in mind
12. The clause with no list at all
Set beside that, the apostrophe clause here is the interesting case, because it is the place where these rules have no list and the annotation rules do. Cutting at the apostrophe is one statement, applied to every apostrophe standing between two letters, and it covers didn’t, it’s, they’re and y’all alike.
didn't -> didn 't
can't -> can 't
won't -> won 't
1990's -> 1990 's
students'-> students '
l'analyse-> l 'analyse under the English setting
l'analyse-> l' analyse under the French settingNothing there is listed and nothing is examined and left alone. The price is that the halves are not morphemes, so didn is not a word and the negation is spelt ’t here where a linguist writes n’t. The gain is that the same clause was written once and turned round for French and Italian by moving the cut to the other side of the mark, which is a setting rather than a second table.
In a model
That trade shows up as a cost in the very thing the rules were built to protect. Over the six sentences of the notebook, these rules produce 49 different pieces and the annotation rules produce 48, and the extra one is didn. The notebook already contains did in the drift did not go away, so the annotation cut reuses a row that already exists and this one opens a row holding a single occurrence. Six sentences are far too few to settle anything, and the direction is still worth reporting, since the whole reason for touching the apostrophe was to stop one word occupying two rows.
Keep in mind
13. An entry says where a word is cut, never what it becomes
A table of this shape is under one constraint that is easy to miss and is the reason the shape survives here at all. The pieces an entry lists must join back to exactly the word the entry names.
…
Without that constraint the obvious entries are tempting. can’t would go to can and not, which reads better than ca and n’t and gives the aligner two real words. What it costs is that a piece stops being a stretch of the source, so the sentence can no longer be reassembled from the pieces and their positions, and it costs it for whichever words happen to be listed rather than uniformly, which is worse than costing it everywhere.
Normalising a word to a different word is a real job and it is done elsewhere in a pipeline, before or after this step, where it can be recorded. The one place these rules do change a piece’s text is the subject of the next part, and they do it in a way that can be read backwards.
Keep in mind
14. One table per language, and one setting that does not choose it
The list of abbreviations is English. A French text handed to these rules gets the English abbreviations checked against it, and the setting that turns the apostrophe cut around does not turn the list around, because there is nothing to turn it to unless somebody has written the French file.
That is the honest description of the method rather than a complaint about it. The original shipped one file per language and the files were contributed by whoever needed that language, so a language is supported exactly when somebody has sat down and listed its abbreviations. On this page every measurement is English, and the French and Italian settings in the playground change only where the apostrophe cut falls.
The running sentence under the French setting
English setting Dr. Alvarez didn 't expect the low-cost re-analysis .
French setting Dr. Alvarez didn' t expect the low-cost re-analysis .One piece boundary moved, from in front of the apostrophe to behind it, and nothing else changed. The title kept its stop under the French setting for the same reason it kept it under the English one, which is that the list consulted is still the English list. A French text gets no help from the setting with its own abbreviations, and an English title inside it would be recognised.
Keep in mind
Part 4. The Round Trip
15. What a translation system hands back is text
Here is the constraint stated plainly. A parser reading a treebank never has to produce the original paragraph, so the annotation rules were free to write things into a piece that were not in the writing. A translation system produces a sentence for somebody to read, so whatever it does on the way in has to be undone on the way out.
The test is simple and it is worth stating before the numbers. Take the pieces, throw away the spans, join them in order with nothing between them, and ask whether what comes out is everything in the source that is not spacing.
…
On the quoted sentence both rule lists give fourteen pieces and they part completely on that test. These rules rewrite nothing and the joined pieces are the sentence. The annotation rules rewrite two pieces, an opening quotation mark into two backquotes and a closing one into two apostrophes, and the joined pieces are not the sentence and cannot be made into it. Over the eighteen minuted sentences the same test passes eighteen times here and seventeen times there.
Keep in mind
16. Two texts, one answer, and no way back
The sharpest way to see why that rewriting cannot be undone is to write a text in the spelling it produces. Take a sentence with quotation marks in it and a second sentence typed with two backquotes and two apostrophes, which is how a typist of the period produced directional quotes on a machine that had none.
she said "wait" and left
she said ``wait'' and leftUnder the annotation rules those two come back as the identical seven pieces. Nothing in the output distinguishes a sentence whose quotation marks were rewritten from a sentence that was typed that way, so anything wanting the original has to keep the original, and the pieces alone are not a division of a text any more. Under these rules the first gives seven pieces and the second gives nine, because a backquote is not a quotation mark and each stands alone, and the two texts are told apart.
Keep in mind
17. The two rewritings these rules do, and why both come back
There are two things these rules will change about a piece’s text, and both are off unless asked for. The first replaces eight characters with names, because a phrase table is a text file whose fields are separated by vertical bars and whose decoder reads angle brackets as markup, so a vertical bar in a training sentence would have been read as a field boundary and corrupted its row.
& -> & | -> |
< -> < > -> >
' -> ' " -> "
[ -> [ ] -> ]Read the mapping in the other direction and every arrow still points at exactly one thing, which is the whole difference from the quotation-mark rewriting of the previous section. Nothing else produces ", so the script that puts the text back together knows what it was reading. With the switch on, our quoted sentence has three pieces whose text is no longer the writing, the two quotation marks and the apostrophe in the contraction, and putting the mapping back recovers the sentence exactly.
The second rewriting is the compound. Cutting low-cost into three lets low and cost share their statistics with every other use of those words, and the piece left in the middle is spelt @-@ rather than - so that the same script can tell a hyphen that joined a compound from a dash that stood between two words. That marker is one character wide in the source and three characters long as a piece, and it undoes to the hyphen it stands for.
The running sentence with every compound cut
Dr. Alvarez didn 't expect the
low @-@ cost re @-@ analysis .Thirteen pieces where there were nine, and the two markers each name a single character of the sentence. Over the eighteen minuted sentences the same switch takes 228 pieces to 240, and over the six-sentence notebook it takes 72 to 84, which is twelve more in each case.
Keep in mind
18. What the round trip does not buy
It is easy to read all this as saying the text comes back, and it does not, quite. Joining the pieces in order recovers every character that is not spacing, and it recovers none of the spacing. Joining them with one space each gives the source for all eighteen minuted sentences when the text was only cut at the spaces, and for two of the eighteen under these rules.
The two that do come back are the sentences that happen to end in an abbreviation, so that every piece was already separated by a space in the writing. The other sixteen have a comma or a final stop standing alone, and a space in front of a comma is not English. Restoring that is the job of the second script that shipped alongside, and it is a set of conventions about a language rather than anything the pieces carry.
So the promise is narrower and more useful than it sounds. The pieces plus their spans plus the source recover everything exactly, and the pieces alone recover every character in order with the spacing to be decided. What the annotation rules give up is the second of those, and it is the one a system with no access to the source has.
Keep in mind
Check yourself
Questions on Parts 3 and 4
Question 1 of 5
A rule that ends a word before n’t has its awkward cases held in a table that is checked before the pattern runs. Why can they not be written into a longer pattern?
Part 5. What It Costs
19. More pieces, and everything downstream pays per piece
The bill is length. Anything reading the text afterwards pays per piece, and a model that compares every position with every other position pays roughly with the square of the count, so a rule that separates marks is spending on every pass over the corpus for the rest of the pipeline’s life.
…
On the eighteen minuted sentences these rules give 228 pieces where splitting on spaces gives 192, which is 18.75 per cent more from identical writing, and the written-out table gives 243 because it also cuts every compound at its hyphen.
228 − 192 = 36 more pieces
36 / 192 = 18.75 per centThe 36 are not spread evenly over the writing. Twenty of them are full stops standing alone, eight are commas and four are quotation marks, which is the 32 pieces holding no letter and no digit, and the rest are the second halves of the contractions and possessives. On the six-sentence notebook these rules give 72, splitting on spaces gives 63, the annotation rules give 72 as well and the table gives 84.
Every rule in that table keeps the same number of characters, 931 on the minutes and 318 on the notebook, which is everything in the writing that is not spacing. That is worth noticing because it is not true of the boundary rules on the earlier page, which find the marks correctly and then discard them. What separates the four here is where the cuts fall.
Keep in mind
20. The vocabulary the rules were meant to shrink
The motive was to make the surface vocabulary smaller, so it is fair to ask whether it did, and the measurement here is the one that surprised me. Over the eighteen minuted sentences, splitting on spaces produces 137 different pieces and these rules produce 136. Over the six-sentence notebook, splitting on spaces produces 47 and these rules produce 49, so at that size the method makes the vocabulary larger.
Nothing is wrong with either number. The mechanism is real and it is visible in the panel above as the words the crude rule spells more than one way, five of them on the minutes and one on the notebook, each an extra row that separating the mark collapses into one. What is missing at this size is repetition. A saving of five rows is paid for by the rows the marks and the contraction halves open, and the two come out level.
Where the 137 and the 136 come from
Lay the two lists of entries for the minutes side by side. They share 106 entries. The crude rule holds 31 that these rules do not, and these rules hold 30 that the crude rule does not.
entries both rules hold 106
only at spaces
a marked run whose word has no other row 24 small. Gov.
a marked run whose word already has a row 5 re-analysis. Okafor,
a contraction 2 didn't It's
at spaces 106 + 24 + 5 + 2 = 137
only under these rules
the words those 24 runs become 24 small Gov
marks standing alone 3 . , "
pieces of a contraction or possessive 3 didn 't 's
under these rules 106 + 24 + 3 + 3 = 136The 24 runs in the first row change their spelling and nothing else, since each gives up a row and the word inside it takes one. The saving is the next two rows, seven entries that go without a new word arriving, and against it stand six new rows that hold no word, three marks and three pieces of a contraction. Seven against six is the saving of one. On the notebook the same accounting gives two entries saved and four opened, which is the loss of two.
In a model
The argument only pays at corpus scale, and the reason is arithmetic rather than linguistics. The rows a mark opens are bounded, since there are a few dozen marks and each of them is one row however often it turns up. The rows a mark costs are not bounded, because every common noun in the language eventually appears with a comma after it, with a stop after it, and inside a pair of brackets.
Of the 137 entries these eighteen sentences give the crude rule, only 5 are a word that reached a second spelling, so the fixed cost of separating the marks is still the larger of the two here. The corpus of proceedings these rules were written for holds millions of sentences, and the fixed cost does not grow with any of them.
Keep in mind
21. Where the annotation rules are ahead
On the minuted corpus the two rule lists produce 228 and 227 pieces and disagree on fourteen entries each way, which the panel above lists in full. Ten of those fourteen are one word with and without a full stop, and they are informative because they do not all run in the same direction.
| in the writing | these rules | the annotation rules | which is right |
|---|---|---|---|
| Gov. Reyes | Gov and a stop | Gov. | the annotation rules |
| Sen. Duarte | Sen and a stop | Sen. | the annotation rules |
| Fig. 4 | Fig and a stop | Fig. | the annotation rules |
| Rev. Santos | Rev and a stop | Rev. | the annotation rules |
| approx. 40 | approx and a stop | approx. | the annotation rules |
| was small. It | small and a stop | small. | these rules |
| by Okafor Co. | Co. | Co and a stop | neither, the stop does both jobs |
| in Jan. | Jan. | Jan and a stop | neither, the stop does both jobs |
| residual, etc. | etc. | etc and a stop | neither, the stop does both jobs |
| until Dec. | Dec. | Dec and a stop | neither, the stop does both jobs |
The ten disagreements that are a full stop. The first five are abbreviations outside the list, the sixth is the positional rule meeting two sentences in one text, and the last four are that rule reaching the end of a text.
Five of the ten go to the annotation rules and one goes to these, and four have no right answer at all and are the subject of the next part. That is a real defeat on a real corpus, and it comes about because the minutes are eighteen separate sentences, which is exactly the arrangement the positional rule was designed for. Run the same rules over the paragraph those eighteen sentences would form and the positional rule loses every internal stop at once, which the previous page measures.
Keep in mind
22. Where the cruder rule wins, and where the annotation rules do
Pointed at writing that is not prose, these rules come apart in the way every rule on these pages does, by separating a character that really is punctuation in a sentence and really is not one here. A company name written with an ampersand becomes three pieces, a percentage becomes two, and an address is cut at the character that makes it an address.
| in the writing | at every run of spaces | these rules | the annotation rules |
|---|---|---|---|
| AT&T signed it. | AT&T | AT and & and T | AT and & and T |
| It rose 40% overnight. | 40% | 40 and % | 40 and % |
| at a@b.com now | a@b.com | a and @ and b.com | a and @ and b.com |
| re-analysis_2019.csv | one piece | re-analysis and _ and 2019.csv | one piece |
The crudest rule is right on all four, since none of these separated characters is punctuation. The last row is the only one where the two rule lists differ, and these rules are the ones that come apart.
The last row is worth dwelling on, because the reason for it is arbitrary rather than principled. A hyphen is one of the characters these rules leave inside a word, so low-cost survives, and an underscore is not on that list, so the file name is cut in two at a character doing exactly the same job. Nothing about writing decides that. It is which characters somebody thought of when the clause was written, and the annotation rules happen to have thought of neither and so keep the whole thing.
Keep in mind
Part 6. Where the Method Stops Being Defined
23. The correctness is a property of a data file
Everything on this page has been a rule except one clause, and that clause decides whether Dr. is one piece or two. Take the list away and the clause has no content, because the three clauses beside it cannot recognise an abbreviation that has no interior stop and is followed by a capital, and that covers most titles at the head of a sentence.
So the method is a rule and a table, and what the method does to a text is not determined until somebody has written the table down. That has three consequences worth separating. The answer for a given text depends on which file was loaded, so two callers running the same rules on the same sentence can get different pieces without either being unfaithful.
The table is per language, so a language nobody has written a file for is not badly handled, it is outside what the method says. And a table is finite while the abbreviations of a language are open, so there is always a next word, and no amount of adding entries changes that.
The practical consequence is about reporting rather than about quality. Two numbers measured on the same corpus by two people who loaded different files are not comparable, and nothing in the output says so, since a word that lost its stop looks the same whether the file was short or the word was genuinely not an abbreviation. Every count on this page was taken with one file of 55 entries in front of the rules, and a file with Gov and Sen in it would move the score in section 8 and the piece counts in section 19 at the same time.
Keep in mind
24. An abbreviation ending a sentence has no answer
There is one case where no list helps and no rule helps, and it is worth stating as a fact about English writing rather than as a shortcoming of anything. A sentence that ends in an abbreviation is written with one full stop, and that stop is closing the abbreviation and closing the sentence at the same time.
The re-analysis was signed by Okafor Co.
Co. is what the abbreviation needs
. is what the sentence needs
Co. and . would invent a characterA division of a text into pieces gives every character to exactly one piece, so the two requirements cannot both be met. Knowing that Co. is an abbreviation does not help, because the question is not what the word is, and the position of the stop does not help, because both readings put it there. These rules answer Co. and lose the sentence’s stop; the annotation rules answer Co and a stop and lose the abbreviation’s. Neither is wrong, and a third method would have to be wrong in one of those two ways as well.
What is genuinely open here is which of the two losses a pipeline would rather have, and that is decided by what reads the pieces. A model counting sentences wants the stop; a table keyed on surface forms wants the abbreviation whole, since the alternative puts a truncated title in a row of its own. Four of the eighteen minuted sentences end this way, which is often enough that the choice has to be made rather than deferred.
Keep in mind
25. Reversibility is a constraint on what a rule may do
The other place the method stops is not a case at all, it is a boundary around the whole method. Requiring that the pieces join back to the writing rules out a large class of things a translation pipeline actually wanted, and those things do not become impossible, they become somebody else’s step.
Lowercasing is the plainest example. A phrase table with The and the as separate rows is wasting evidence in exactly the way this method exists to prevent, and folding the case is a rewriting that cannot be read backwards, since the does not say whether it began a sentence. Expanding a contraction, normalising a spelling, mapping a number to a placeholder and stripping an accent are the same shape.
So a method under this constraint splits a pipeline in two. One half is a division of the writing, which is what these rules are, and the other half is a sequence of changes that a caller must record if it wants them back. The two changes this method does allow itself are exactly the two that arrive with an inverse written down beside them, a table of eight characters and one marker standing for a hyphen, and what admitted them was that the mapping can be read in either direction rather than that they were useful.
Keep in mind
26. What is left undecided, gathered
The cases below are gathered from the whole page. The right column says what the method does not determine and why, and it quotes a number where the number is a fact about the method rather than about any particular text.
| the case | what is undefined, or what must be decided |
|---|---|
| an abbreviation ending a sentence | undecidable, with or without a list, because one character closes both the abbreviation and the sentence and a division of the text gives every character to exactly one piece. What must be decided is which loss to take, and the two rule lists on these pages take opposite ones. Four of the eighteen sentences here end this way. |
| an abbreviation nobody listed | cut, and indistinguishable from a word the clauses examined and left alone. Nothing reports that a list was consulted and found nothing. Eighteen sentences of the register the rules were made for reach 19 of the 55 entries and contain five abbreviations outside them. |
| which table is loaded | assumed, never determined. The rule is exact relative to a table and the table is a document somebody maintains, so the same rules over the same sentence give different pieces to two callers holding different files, and neither is being unfaithful. |
| a language with no table | outside what the method says rather than handled badly. Every measurement on this page is English. The setting that turns the apostrophe cut around for French and Italian does not turn the abbreviations around, because a list of abbreviations for a language is written by somebody who knows it. |
| where the cut goes inside a contraction | not settled by the writing. Cutting at the mark and cutting in front of the morpheme both give pieces that join back to the word, and what chooses is whether the pieces are meant to align to units of another language. Over six sentences that single choice costs one extra row, since didn is a form the corpus holds nowhere else. |
| restoring the spacing | outside the method entirely. Joining the pieces in order recovers every character that is not spacing and none of the spacing, and joining them with one space each reproduces 2 of the 18 sentences here against 18 for the rule that only cuts at spaces. Where the spaces go is a set of conventions about a language. |
| a rewriting with no inverse | refused rather than performed. Lowercasing, expanding a contraction and normalising a spelling all shrink the surface vocabulary, which is the method's own aim, and none can be read backwards, so each has to be a separate step that records what it did. |
| a rewriting whose output could have been typed | undoable only when nothing else produces the same characters. That holds for the eight named characters here and fails for the annotation rules' quotation marks, where two texts that differ come back as one identical answer of seven pieces. |
| writing that is not prose | outside what the rules were written for. An address is cut at the character that makes it an address, while a file name that the boundary rules cut into three survives whole here. What has to be decided is whether such stretches are protected before any rule sees them, since none of the four will say it met one. |
Keep in mind
Check yourself
Questions on Parts 5 and 6
Question 1 of 5
The motive was to make the surface vocabulary smaller. What did measuring it find?
Try it with Botie
Build with Botie
Write and run Python