A Generative Model for Punctuation in Dependency Trees
Xiang Lisa Li Dingquan Wang Jason Eisner

Pattern formation during deformation of metallic nanolaminates
    Lars Pastewka
    December 30, 2023
==============================================================

plain
plain


    Treebanks traditionally treat punctuation marks as ordinary words, but linguists have suggested that a tree's “true” punctuation marks are not observed <cit.>.  These latent “underlying” marks serve to delimit or separate constituents in the syntax tree.  When the tree's yield is rendered as a written sentence, a string rewriting mechanism transduces the underlying marks into “surface” marks, which are part of the observed (surface) string but should not be regarded as part of the tree.  We formalize this idea in a generative model of punctuation that admits efficient dynamic programming. We train it without observing the underlying marks, by locally maximizing the incomplete data likelihood (similarly to the EM algorithm).  When we use the trained model to reconstruct the tree's underlying punctuation, the results appear plausible across 5 languages, and in particular are consistent with Nunberg's analysis of English.  We show that our generative model can be used to beat baselines on punctuation restoration. Also, our reconstruction of a sentence's underlying punctuation lets us appropriately render the surface punctuation (via our trained underlying-to-surface mechanism) when we syntactically transform the sentence.






§ INTRODUCTION



Punctuation enriches the expressiveness of written language.
When converting from spoken to written language, punctuation indicates pauses or pitches; expresses propositional attitude; and is conventionally associated with certain syntactic constructions such as apposition, parenthesis, quotation, and conjunction.

In this paper, we present a latent-variable model of punctuation usage, inspired by the rule-based approach to English punctuation of <cit.>.  
Training our model on English data learns rules that are consistent with Nunberg’s hand-crafted rules.  
Our system is automatic, so we use it to obtain rules for Arabic, Chinese, Spanish, and Hindi as well. 

Moreover, our rules are stochastic, which allows us to reason probabilistically about ambiguous or missing punctuation.
 Across the 5 languages, our model predicts surface punctuation better than baselines, as measured both by perplexity (<ref>) and by accuracy on a punctuation restoration task (<ref>).  We also use our model to correct the punctuation of non-native writers of English (<ref>), and to maintain natural punctuation style when syntactically transforming English sentences (<ref>).  In principle, our model could also be used within a generative parser, allowing the parser to evaluate whether a candidate tree truly explains the punctuation observed in the input sentence (<ref>).



  
Punctuation is interesting 
In The Linguistics of Punctuation, <cit.> argues that punctuation (in English) is more than a visual counterpart of spoken-language prosody, but forms a linguistic system that involves “interactions of point indicators (i.e. commas, semicolons, colons, periods and dashes).” He proposes that much as in phonology <cit.>,
a grammar generates underlying punctuation which then transforms into the observed surface punctuation.

Consider generating a sentence from a syntactic grammar as follows:

  Hail the king [, Arthur Pendragon ,]
      [, who wields [ “ Excalibur ” ] ,] .

Although the full tree is not depicted here, some of the constituents are indicated with brackets.  In this underlying generated tree, each appositive NP is surrounded by commas.  On the surface, however, the two adjacent commas after Pendragon will now be collapsed into one, and the final comma will be absorbed into the adjacent period.  Furthermore, in American English, the typographic convention is to move the final punctuation inside the quotation marks.  Thus a reader sees only this modified surface form of the sentence: 

  Hail the king, Arthur Pendragon,
      who wields “Excalibur.”

Note that these modifications are string transformations that do not see or change the tree.
The resulting surface punctuation marks may be clues to the parse tree, but (contrary to NLP convention) they should not be included as nodes in the parse tree.  Only the underlying marks play that role.



  
Punctuation is meaningful 
<cit.> use question and exclamation marks as clues to sentiment.  Similarly, quotation marks may be used to mark titles, quotations, reported speech, or dubious terminology
<cit.>.  Because of examples like this, methods for determining the similarity or meaning of syntax trees, such as a tree kernel <cit.> or a recursive neural network <cit.>, should ideally be able to consider where the underlying punctuation marks attach.



  
Punctuation is helpful 
Surface punctuation remains correlated with syntactic phrase structure.  NLP systems for generating or editing text must be able to deploy surface punctuation as human writers do.  Parsers and grammar induction systems benefit from the presence of surface punctuation marks <cit.>. It is plausible that they could do better with a linguistically informed model that explains exactly why the surface punctuation appears where it does.  Patterns of punctuation usage can also help identify the writer's native language <cit.>.



  
Punctuation is neglected
Work on syntax and parsing tends to treat punctuation as an afterthought rather than a phenomenon governed by its own linguistic principles.
Treebank annotation guidelines for punctuation tend to adopt simple heuristics like “attach to the highest possible node that preserves projectivity” <cit.>.[<http://universaldependencies.org/u/dep/punct.html>]
Many dependency parsing works exclude punctuation from evaluation <cit.>, although some others retain punctuation <cit.>.

In tasks such as word embedding induction <cit.> and machine translation <cit.>, punctuation marks are usually either removed or treated as ordinary words <cit.>.
However, punctuation marks are special: they often come in matched pairs, and they are subject to orthographic rewrite rules as discussed above.

Yet to us, building a parse tree on a surface sentence seems as inappropriate as morphologically segmenting a surface word.  In both cases, one should instead analyze the latent underlying form, jointly with recovering that form.  For example, the proper segmentation of English hoping is not hop-ing but hope-ing (with underlying e), and the proper segmentation of stopping is neither stopp-ing nor stop-ping but stop-ing (with only one underlying p). cotterell-peng-eisner-2015,cotterell-vieira-schuetze-2016 get this right for morphology.  We attempt to do the same for punctuation.



§ FORMAL MODEL


























We propose a probabilistic generative model of sentences (<ref>):

    () = ∑_,() · p_(|) · p_(|()) 30pt

First, an unpunctuated dependency tree  is stochastically generated by some recursive process  <cit.>.[Our model could be easily adapted to work on constituency trees instead.]  
Second, each constituent (i.e., dependency subtree) sprouts optional underlying punctuation at its left and right edges, according to a probability distribution p_ that depends
on the constituent's syntactic role (e.g., dobj for “direct object”).
This punctuated tree  yields the underlying string = (), which is edited by a finite-state noisy channel p_ to arrive at the surface sentence .  

This third step may alter the sequence of punctuation tokens at each slot between words—for example, in <ref>, collapsing the double comma , , between Pendragon and who.
 and  denote just the punctuation at the slots of  and  respectively, with _i and _i denoting the punctuation token sequences at the ith slot.  Thus, the transformation at the ith slot is _i ↦_i.

Since this model is generative, we could train it without any supervision to explain the observed surface string : maximize the likelihood p() in (<ref>), marginalizing out the possible , values.

In the present paper, however, we exploit known  values (as observed in the “depunctuated” version of a treebank).  Because  is observed, we can jointly train , to maximize just

    p(|) = ∑_ p_(|) · p_(|())

That is, the  model that generated  becomes irrelevant, but we still try to predict what surface
punctuation will be added to .
We still marginalize over the underlying punctuation marks .  These are never observed, but they must explain the surface punctuation marks  (<ref>), and they must be explained in turn by the syntax tree  (<ref>).  The trained generative model then lets us restore or correct punctuation in new trees  (<ref>).



 §.§ Generating Underlying Punctuation







   







The  model characterizes the probability of an underlying punctuated tree  given its corresponding unpunctuated tree , which is given by

    _(|) = ∏_∈_(_, _|)

where _, _∈ are the left and right punctemes that  attaches to the tree node .  Each puncteme <cit.> in the finite set  is a string of 0 or more underlying punctuation tokens.[Multi-token punctemes are occasionally useful.  For example, the puncteme ... might consist of either 1 or 3 tokens, depending on how the tokenizer works; similarly, the puncteme ?! might consist of 1 or 2 tokens. Also, if a single constituent of  gets surrounded by both parentheses and quotation marks, this gives rise to punctemes (“ and ”).  (A better treatment would add the parentheses as a separate puncteme pair at a unary node above the quotation marks, but that would have required  to introduce this extra node.)]
The probability _(, |) is given by a log-linear model


    _(,  | ) 
         ∝exp^⊤(, , )    if (,)∈_()
    
         0    otherwise10pt


where  is the finite set of possible punctemes and _⊆^2 gives the possible puncteme pairs for a node  that has dependency relation =() to its parent.   and _ are estimated heuristically from the tokenized surface data (<ref>).  (, , ) is a sparse binary feature vector, and  is the corresponding parameter vector of feature weights.  The feature templates in sec:template
[ The appendices are included only in this arXiv version, not in the TACL journal.]
  consider the symmetry between l and r, and their compatibility with (a) the POS tag of 's head word, (b) the dependency paths connecting  to its children and the root of , (c) the POS tags of the words flanking the slots containing l and r, (d) surface punctuation already added to 's subconstituents (bottom-up).



 §.§ From Underlying to Surface

























From the tree , we can read off the sequence of underlying punctuation tokens _i at each slot i between words.  Namely, _i concatenates the right punctemes of all constituents ending at i with the left punctemes of all constituents starting at i (as illustrated by the examples in <ref> and <ref>). 
 The  model then transduces _i to a surface token sequence _i, for each i = 0,…,n independently (where n is the sentence length).



  
Nunberg's formalism
Much like ChomskyHalle68 phonological grammar of English, nunberg1990linguistics descriptive English punctuation grammar (<ref>) can be viewed computationally as a priority string rewriting system, or Markov algorithm <cit.>.
The system begins with a token string .  At each step it selects the highest-priority local rewrite rule that can apply, and applies it as far left as possible. When no more rules can apply, the final state of the string is returned as .



  
Simplifying the formalism Markov algorithms are Turing complete.  Fortunately, <cit.> noted that in practice, phonological ↦ maps described in this formalism can usually be implemented with finite-state transducers (FSTs).  

For computational simplicity, we will formulate our punctuation model as a probabilistic FST (PFST)—a locally normalized left-to-right rewrite model <cit.>.  The probabilities for each language must be learned, using gradient descent.  Normally we expect most probabilities to be near 0 or 1, making the PFST nearly deterministic (i.e., close to a subsequential FST).  However, permitting low-probability choices remains useful to account for typographical errors, dialectal differences, and free variation in the training corpus.

Our PFST generates a surface string, but the invertibility of FSTs will allow us to work backwards when analyzing a surface string (<ref>).















  
A sliding-window model
Our specific model can be understood as follows.
Instead of having rule priorities, we apply Nunberg-style rules within a 2-token window that slides over  in a single left-to-right pass (<ref>).
Conditioned on the current window contents ab, a single edit is selected stochastically: either ab ab (no change), ab b (left absorption), ab a (right absorption), or ab ba (transposition).  Then the window slides rightward to cover the next input token, together with the token that is (now) to its left.  a and b are always real tokens, never boundary symbols.  
 specifies the conditional edit probabilities.[Rather than learn a separate edit probability distribution for each bigram ab, one could share parameters across bigrams.  For example, <ref>'s caption says that “stronger” tokens tend to absorb “weaker” ones.  A model that incorporated this insight would not have to learn O(||^2) separate absorption probabilities (two per bigram ab), but only O(||) strengths (one per unigram a, which may be regarded as a 1-dimensional embedding of the punctuation token a).  We figured that the punctuation vocabulary  was small enough (<ref>) that we could manage without the additional complexity of embeddings or other featurization, although this does presumably hurt our generalization to rare bigrams.]

These specific edit rules (like Nunberg's) cannot insert new symbols, nor can they delete all of the underlying symbols.  Thus, surface _i is a good clue to _i: all of its tokens must appear underlyingly, and if _i = ϵ (the empty string) then _i = ϵ.  

The model can be directly implemented as a PFST (sec:pfstft:supp) using cotterell14 more general PFST construction.

Our single-pass formalism is less expressive than Nunberg's.  It greedily makes decisions based on at most one token of right context (“label bias”).  It cannot rewrite '”..'” or ”,..” because the . is encountered too late to percolate leftward; luckily, though, we can handle such English examples by sliding the window right-to-left instead of left-to-right.  We treat the sliding direction as a language-specific parameter.[We could have handled all languages uniformly by making ≥ 2 passes of the sliding window (via a composition of ≥ 2 PFSTs), with at least one pass in each direction.]






 §.§ Training Objective







Building on <ref>, we train , to locally maximize the regularized conditional log-likelihood

    ( ∑_,log p(|) 
          - ξ·[]c()^2 )
         - ς·||||^2 8pt




where the sum is over a training treebank.[In retrospect, there was no good reason to square the []c() term.  However, when we started redoing the experiments, we found the results essentially unchanged.]

The expectation ⋯ is over ∼(·|,).  This generalized expectation term provides posterior regularization <cit.>, by encouraging parameters that reconstruct trees  that use symmetric punctuation marks in a “typical” way. The function c() counts the nodes in  whose punctemes contain “unmatched” symmetric punctuation tokens: for example, ) is “matched” only when it appears in a right puncteme with ( at the comparable position in the same constituent's left puncteme. 
The precise definition uses a “universal” list of 12 symmetric pairs (<ref>ft:supp)
is given in sec:pr.ft:supp

In our development experiments on English, the posterior regularization term was necessary to discover an aesthetically appealing theory of underlying punctuation.  When we dropped this term (ξ = 0) and simply maximized the ordinary regularized likelihood, we found that the optimization problem was underconstrained: different training runs would arrive at different, rather arbitrary underlying punctemes.  For example, one training run learned an  model that used underlying  to terminate sentences, along with a  model that absorbed the left quotation mark into the period.  By encouraging the underlying punctuation to be symmetric, we broke the ties.  We also tried making this a hard constraint (ξ = ∞), but then the model was unable to explain some of the training sentences at all, giving them probability of 0.  For example,  cannot be explained, because  is not a constituent.[Recall that the  model family (<ref>) requires the surface  before  to appear underlyingly, and also requires the surface ϵ after  to be empty underlyingly.  These hard constraints clash with the ξ=∞ hard constraint that the punctuation around  must be balanced.  The surface  after  causes a similar problem: no edge can generate the matching underlying .]









§ INFERENCE



























In principle, working with the model (<ref>) is straightforward, thanks to the closure properties of formal languages.  Provided that  can be encoded as a weighted CFG, it can be composed with the weighted tree transducer p_ and the weighted FST p_ to yield a new weighted CFG <cit.>.
  Under this new grammar, one can recover the optimal T,T' for  by dynamic programming, or sum over T,T' by the inside algorithm to get the likelihood p().
A similar approach
was used by <cit.> with a different FST noisy channel.

In this paper we assume that  is observed, allowing us to work with <ref>.  This cuts the computation time from O(n^3) to O(n).[We do O(n) multiplications of N × N matrices where N = O(# of punc types·max # of punc tokens per slot).]
Whereas the inside algorithm for (<ref>) must consider O(n^2) possible constituents of  and O(n) ways of building each, our algorithm for (<ref>) only needs to iterate over the O(n) true constituents of  and the 1 true way of building each.  However, it must still consider the |_| puncteme pairs for each constituent.


[1]#1
[1]#1
[1][t]--▹ #1








 §.§ Algorithms
 












Given an input sentence  of length n, our job is to sum over possible trees  that are consistent with  and , or to find the best such .  This is roughly a lattice parsing problem—made easier by knowing .  However, the possible  values are characterized not by a lattice but by a cyclic WFSA (as |_i| is unbounded whenever |_i|>0). 

For each slot 0 ≤ i ≤ n, transduce the surface punctuation string _i by the inverted PFST for p_ to obtain a weighted finite-state automaton (WFSA) that describes all possible underlying strings _i.[Constructively, compose the -to- PFST (from the end of <ref>) with a straight-line FSA accepting only _i, and project the resulting WFST to its input tape <cit.>, as explained at the end of sec:pfst.]
This WFSA accepts each possible _i with weight _(_i |_i).  If it has N_i states, we can represent it <cit.> with a family of sparse weight matrices _i() ∈^N_i × N_i, whose element at row s and column t is the weight of the s → t arc labeled with , or 0 if there is no such arc.  Additional vectors λ⃗_i, ρ⃗_i ∈^N_i specify the initial and final weights.
 (λ⃗_i is one-hot if the PFST has a single initial state, of weight 1.)

For any puncteme  (or r) in , we define _i() = _i(_1)_i(_2)⋯_i(_||), a product over the 0 or more tokens in .  This gives the total weight of all s →^* t WFSA paths labeled with .

The subprocedure in <ref> essentially extends this to obtain a new matrix ∈^N_i × N_k, where the subtree rooted at  stretches from slot i to slot k.  Its element _st gives the total weight of all extended paths in the  WFSA from state s at slot i to state t at slot k.  An extended path is defined by a choice of underlying punctemes at  and all its descendants.  These punctemes determine an s-to-final path at i, then initial-to-final paths at i+1 through k-1, then an initial-to-t path at k.  The weight of the extended path is the product of all the WFSA weights on these paths (which correspond to transition probabilities in p_ PFST) times the probability of the choice of punctemes (from p_).

This inside algorithm computes quantities 
needed for training (<ref>).  Useful variants arise via well-known methods for weighted derivation forests <cit.>.  

Specifically, to modify <ref> to maximize over  values (sec:corrsec:gd) instead of summing over them, we switch to the derivation semiring <cit.>, as follows. Whereas _st used to store the total weight of all extended paths from state s at slot i to state t at slot j, now it will store the weight of the best such extended path.  It will also store that extended path's
  choice of underlying punctemes, in the form of a puncteme-annotated version of the subtree of  that is rooted at .  This is a potential subtree of . 

Thus, each element of  has the form (r,) where r ∈ and  is a tree.  We define addition and multiplication over such pairs:

    (r,) + (r',')    = 
        
          (r,)    if  r > r' 
    
          (r',')    otherwise
    
    (r,) · (r',')    = (rr', ')

where ' denotes an ordered combination of two trees.  Matrix products U⃗V⃗ and scalar-matrix products p·V⃗ are defined in terms of element addition and multiplication as usual:


    (U⃗V⃗)_st   = ∑_rU⃗_sr·V⃗_rt
    
      (p·V⃗)_st   = p ·V⃗_st


What is DD'? For presentational purposes, it is convenient to represent a punctuated dependency tree as a bracketed string.  For example, the underlying tree  in <ref> would be 
where the words correspond to nodes of .
In this case, we can represent every  as a partial bracketed string and define ' by string concatenation.  This presentation ensures that multiplication (<ref>) is a complete and associative (though not commutative) operation, as in any semiring.  As base cases, each real-valued element of _i() or _k() is now paired with the string  or  respectively,
[We still construct the real matrix _i() by ordinary matrix multiplication before pairing its elements with strings.  This involves summation of real numbers: each element of the resulting real matrix is a marginal probability, which sums over possible PFST paths (edit sequences) that could map the underlying puncteme  to a certain substring of the surface slot _i.  Similarly for _k().]
and the real number 1 at <ref> is paired with the string .  The real-valued elements of the λ⃗_i and ρ⃗_i vectors and the 0⃗ matrix at <ref> are paired with the empty string ϵ, as is the real number p at <ref>.

In practice, the  strings that appear within the matrix  of <ref> will always represent complete punctuated trees.  Thus, they can actually be represented in memory as such, and different trees may share subtrees for efficiency (using pointers).  The product in <ref> constructs a matrix of trees with root w and differing sequences of left/right children, while the product in <ref> annotates those trees with punctemes ,.

To sample a possible  from the derivation forest in proportion to its probability (<ref>),
we use the same algorithm but replace <ref> with

    (r,) + (r',')    = 
      
        (r+r',)    if  u < r/r+r'
    
        (r+r',')    otherwise

with u ∼Uniform(0,1) being a random number.



 §.§ Optimization

Having computed the objective (<ref>), we find the gradient via automatic differentiation, and optimize , via Adam <cit.>—a variant of stochastic gradient decent—with learning rate 0.07, batchsize 5, sentence per epoch 400, and L2 regularization.  (These hyperparameters, along
with the regularization coefficients ς and ξ from <ref>, were tuned on dev data (<ref>) for each language respectively.)
We train the punctuation model for 30 epochs. The initial  parameters () are drawn from N(0,1), and the initial  parameters () are drawn from N(0,1) (with one minor exception described in sec:template).



§ INTRINSIC EVALUATION OF THE MODEL






  
Data. Throughout sec:expsec:app,
we will examine the punctuation model on a subset of the Universal Dependencies (UD) version 1.4 <cit.>[It contains the latest treebank of English as a Second Language (en_esl) data, which is used in our experiments.]—a collection of dependency treebanks across 47 languages with unified POS-tag and dependency label sets.  Each treebank has designated training, development, and test portions.  We experiment on Arabic, English, Chinese, Hindi, and Spanish (<ref>)—languages with diverse punctuation vocabularies and punctuation interaction rules, not to mention script directionality.  
For each treebank, we use the tokenization provided by UD, and take the punctuation tokens (which may be multi-character, such as ...) to be the tokens with the PUNCT tag.  
We replace each straight double quotation mark " with either “ or ” as appropriate, and similarly for single quotation marks.[For en and en_esl, “ and ” are distinguished by language-specific part-of-speech tags. For the other 4 languages, we identify two " dependents of the same head word, replacing the left one with  “ and the right one with ”.  ]
We split each non-punctuation token that ends in . (such as etc.) into a shorter non-punctuation token (etc) followed by a special punctuation token called the “abbreviation dot” (which is distinct from a period).
We prepend a special punctuation mark  to every sentence , which can serve to absorb an initial comma, for example.[For symmetry, we should also have added a final mark.]
We then replace each token with the special symbol UNK if its type appeared fewer than 5 times in the training portion.  This gives the surface sentences.

To estimate the vocabulary  of underlying punctemes, we simply collect all surface token sequences _i that appear at any slot in the training portion of the processed treebank.  This is a generous estimate.  Similarly, we estimate _ (<ref>) as all pairs (,) ∈^2 that flank any  constituent.

Recall that our model generates surface punctuation given an unpunctuated dependency tree.  We train it on each of the 5 languages independently.  We evaluate on conditional perplexity, which will be low if the trained model successfully assigns a high probability to the actual surface punctuation in a held-out corpus of the same language.




  
Baselines. 
We compare our model against three baselines to show that its complexity is necessary.
Our first baseline is an ablation study that does not use latent underlying punctuation, but generates the surface punctuation directly from the tree.  (To implement this, we fix the parameters of the noisy channel so that the surface punctuation equals the underlying with probability 1.)  If our full model performs significantly better, it will demonstrate the importance of a distinct underlying layer. 

Our other two baselines ignore the tree structure, so if our full model performs significantly better, it will demonstrate that conditioning on explicit syntactic structure is useful.  These baselines are based on previously published approaches that reduce the problem to tagging: 
<cit.> use a BiLSTM-CRF tagger with bigram topology;
<cit.> use a BiGRU tagger with attention.  
In both approaches, the model is trained to tag each slot i with the correct string _i ∈ (possibly ϵ or ).
These are discriminative probabilistic models (in contrast to our generative one).  Each gives a probability distribution over the taggings (conditioned on the unpunctuated sentence), so we can evaluate their perplexity.[These methods learn word embeddings that optimize conditional log-likelihood on the  punctuation restoration training data.  They might do better if these embeddings were shared with other tasks, as multi-task learning might lead them to discover syntactic categories of words.] 



  
Results.

As shown in <ref>, our full model beats the baselines in perplexity in all 5 languages. Also,
in 4 of 5 languages, allowing a trained  (rather than the identity map) significantly improves the perplexity.








§ ANALYSIS OF THE LEARNED GRAMMAR




 §.§ Rules Learned from the Noisy Channel



We study our learned probability distribution over noisy channel rules (ab b, ab a, ab ab, ab ba) for English.
The probability distributions corresponding to six of Nunberg's English rules are shown in <ref>. 
By comparing the orange and blue bars, observe that the model trained on the en_cesl treebank learned different quotation rules from the one trained on the en treebank. This is because en_cesl follows British style,[The ESL data comes from Cambridge ESOL First Certificate in English (FCE) examination, which is a British exam, so the corrected punctuation follows the British style.] whereas en has American-style quote transposition.[American style places commas and periods inside the quotation marks, even if they are not logically in the quote. British style (more sensibly) places unquoted periods and commas in their logical place, sometimes outside the quotation marks if they are not part of the quote.]



We now focus on the model learned from the en treebank.  Nunberg's rules are deterministic, and our noisy channel indeed learned low-entropy rules, in the sense that for an input ab with underlying count ≥ 25,[For rarer underlying pairs ab, the estimated distributions sometimes have higher entropy due to undertraining.] at least one of the possible outputs (a, b, ab or ba) always has probability > 0.75.
The one exception is ”..” for which the argmax output has probability ≈ 0.5,
because writers do not apply this quote transposition rule consistently. As shown by the blue bars in <ref>, the high-probability transduction rules are consistent with Nunberg's hand-crafted deterministic grammar in <ref>.

Our system has high precision when we look at the confident rules.  Of the 24 learned edits with conditional probability > 0.75, Nunberg lists 20.

Our system also has good recall.  Nunberg's hand-crafted schemata consider 16 punctuation types and generate a total of 192 edit rules, including the specimens in <ref>.  That is, of the 16^2 = 256 possible underlying punctuation bigrams ab, 3/4 are supposed to undergo absorption or transposition.  Our method achieves fairly high recall, in the sense that when Nunberg proposes ab γ, our learned p(γ| ab) usually ranks highly among all probabilities of the form p(γ' | ab).  75 of Nunberg's rules got rank 1, 48 got rank 2,
and the remaining 69 got rank > 2.  The mean reciprocal rank was 0.621.  Recall is quite high when we restrict to those Nunberg rules ab γ for which our model is confident how to rewrite ab, in the sense that some p(γ' | ab) > 0.5.  (This tends to eliminate rare ab: see <ref>.)  Of these 55 Nunberg rules, 38 rules got rank 1, 15 got rank 2,
and only 2 got rank worse than 2. The mean reciprocal rank was 0.836. 

¿What about Spanish?  Spanish uses inverted question marks ¿ and exclamation marks ¡, which form symmetric pairs with the regular question marks and exclamation marks. If we try to extrapolate to Spanish from Nunberg's English formalization, the English mark most analogous to  ¿ is (. Our learned noisy channel for Spanish (not graphed here) includes the high-probability rules ,¿,¿ and :¿:¿ and ¿,¿ which match Nunberg's treatment of ( in English. 



 §.§ Attachment Model






What does our model learn about how dependency relations are marked by underlying punctuation? 

The above example[[en]  ] illustrates the use of specific puncteme pairs to set off the advmod, ccomp, and nmod relations. Notice that said takes a complement (ccomp) that is symmetrically quoted but also left delimited by a comma, which is indeed how direct speech is punctuated in English. This example also illustrates quotation transposition. The top five relations that are most likely to generate symmetric punctemes and their top (,) pairs are shown in <ref>. 

 

The above example[[en] ]
shows how our model handles commas in conjunctions of 2 or more phrases.  UD format dictates that each conjunct after the first is attached by the conj relation.  As shown above, each such conjunct is surrounded by underlying commas (via the .,.,.conj feature from sec:template), except for the one that bears the conjunction  (via an even stronger weight on the .ϵ.ϵ.conj.cc feature).  Our learned feature weights indeed yield p(ℓ=ϵ,r=ϵ) > 0.5 for the final conjunct in this example.  Some writers omit the “Oxford comma” before the conjunction: this style can be achieved simply by changing “surrounded” to “preceded” (that is, changing the  feature to .,.ϵ.conj).



§ PERFORMANCE ON EXTRINSIC TASKS



We evaluate the trained punctuation model by using it in the following three tasks. 



 §.§ Punctuation Restoration


In this task, we are given a depunctuated sentence [ To depunctuate a treebank sentence, we remove all tokens with POS-tag  or dependency relation .  These are almost always leaves; else we omit the sentence.] and must restore its (surface) punctuation.  Our model supposes that the observed punctuated sentence  would have arisen via the generative process (<ref>). Thus, we try to find , , and  that are consistent with  (a partial observation of ).

 

The first step is to reconstruct  from .  This initial parsing step is intended to choose the  that maximizes (|).[Ideally, rather than maximize, one would integrate over possible trees , in practice by sampling many values _k from (·|) and replacing S(T) in (<ref>) with ⋃_k S(T_k).] This step depends only on  and not on our punctuation model (p_,
  p_).
  In practice, we choose  via a dependency parser that has been trained on an unpunctuated treebank with examples of the form (,).[Specifically, the Yara parser <cit.>, a fast non-probabilistic transition-based parser that uses rich non-local features <cit.>.]  

<Ref> now defines a distribution over (,) 
given this .  To obtain a single prediction for , we adopt the minimum Bayes risk (MBR) approach of choosing surface punctuation  that minimizes the expected loss with respect to the unknown truth ^*.  Our loss function is the total edit distance over all slots (where edits operate on punctuation tokens).  Finding  exactly would be intractable, so we use a sampling-based approximation and draw m=1000 samples from the posterior distribution over (,). We then define 


    =  _∈ S()∑_^* ∈ S()p̂(^* | ) ·loss(,^*)

where S() is the set of unique  values in the sample and p̂ is the empirical distribution given by the sample.  This can be evaluated in O(m^2) time.

We evaluate on Arabic, English, Chinese, Hindi, and Spanish.  For each language, we train both the parser and the punctuation model on the training split of that UD treebank (<ref>), and evaluate on held-out data.  We compare to the BiLSTM-CRF baseline in <ref> <cit.>.[We copied their architecture exactly but re-tuned the hyperparameters on our data.  We also tried tripling the amount of training data by adding unannotated sentences (provided along with the original annotated sentences by 11234/1-1989), taking advantage of the fact that the BiLSTM-CRF does not require its training sentences to be annotated with trees.  However, this actually hurt performance slightly, perhaps because the additional sentences were out-of-domain.  We also tried the BiGRU-with-attention architecture of <cit.>, but it was also weaker than the BiLSTM-CRF (just as in <ref>).  We omit all these results from <ref> to reduce clutter.] 
We also compare to a “trivial” deterministic baseline, which merely places a period at the end of the sentence  (or a "" in the case of Hindi) and adds no other punctuation.  Because most slots do not in fact have punctuation, the trivial baseline already does very well; to improve on it, we must fix its errors without introducing new ones.















Our final comparison on test data is shown in the table in <ref>.  On all 5 languages, our method beats (usually significantly) its 3 competitors: the trivial deterministic baseline, the BiLSTM-CRF, and the ablated version of our model () that omits the noisy channel.

Of course, the success of our method depends on the quality of the parse trees  (which is particularly low for Chinese and Arabic).  The graph in <ref> explores this relationship, by evaluating (on dev data) with noisier trees obtained from parsers that were variously trained on only the first 10%, 20%, …of the training data.  On all 5 languages, provided that the trees are at least 75% correct, our punctuation model beats both the trivial baseline and the BiLSTM-CRF (which do not use trees).
It also beats the  ablation baseline at all levels of tree accuracy (these curves are omitted from the graph to avoid clutter).  In all languages, better parses give better performance, and gold trees yield the best results.









 §.§ Punctuation Correction


Our next goal is to correct punctuation errors in a learner
corpus.
Each sentence is drawn from the Cambridge Learner Corpus treebanks, which provide original (en_esl) and corrected (en_cesl) sentences. 
All kinds of errors are corrected, such as syntax errors, but we use only the 30% of sentences whose depunctuated trees  are isomorphic between en_esl and en_cesl.  These en_cesl trees may correct word and/or punctuation errors in en_esl, as we wish to do automatically.

We assume that an English learner can make mistakes in both the attachment and the noisy channel steps.  A common attachment mistake is the failure to
surround a non-restrictive relative clause with commas. In the noisy channel step, mistakes in quote transposition are common.A further step would be to model typos by adding another noisy channel, which we didn't implement in this experiment.




  







  
Correction model.
Based on the assumption about the two error sources, we develop a discriminative model for this task.  Let  denote the full input sentence, and let  and  denote the input (possibly errorful) and output (corrected) punctuation sequences.  
We model p(|) = ∑_∑__c(|) · p_(_c|,) · p_ (|_c).  Here  is the depunctuated parse tree, _c is the corrected underlying tree, _e is the error underlying tree, and we assume
. 

In practice we use a 1-best pipeline rather than summing.  
Our first step is to reconstruct  from the error sentence . We choose  that maximizes (|) from a dependency parser trained on en_esl treebank examples (, ). 
The second step is to reconstruct _e based on our punctuation model trained on en_esl. We choose _e that maximizes p(_e|,).
We then reconstruct _c by 


    (_c |_e) = ∏__e∈_e (, |_e)

where _e is the node in _e, and (, |_e) is a similar log-linear model to <ref> with additional features (sec:template_corrft:supp)
which look at _e.

Finally, we reconstruct  based on the noisy channel p_ (|_c) in <ref>. During training,  is regularized to be close to the noisy channel parameters in the punctuation model trained on en_cesl.

We use the same MBR decoder as in <ref> to choose the best action. We evaluate using AED as in <ref>.  As a second metric, we use the script from the CoNLL 2014 Shared Task on Grammatical Error Correction <cit.>: it computes the F_0.5-measure of the set of edits found by the system, relative to the true set of edits.

As shown in <ref>, our method achieves better performance than the punctuation restoration baselines (which ignore input punctuation).  On the other hand, it is soundly beaten by a new BiLSTM-CRF that we trained specifically for the task of punctuation correction.  This is the same as the BiLSTM-CRF in the previous section, except that the BiLSTM now reads a punctuated input sentence (with possibly erroneous punctuation) instead of an unpunctuated one.  To be precise, at step 0 ≤ i ≤ n, the BiLSTM reads a concatenation of the embedding of word i (or  if i=0) with an embedding of the punctuation token sequence _i.
The BiLSTM-CRF wins because it is a discriminative model tailored for this task: the BiLSTM can extract arbitrary contextual features of slot i that are correlated with whether _i is correct in context.





 §.§ Sentential Rephrasing



We suspect that syntactic transformations on a sentence should often preserve the underlying punctuation attached to its tree.  The surface punctuation can then be regenerated from the transformed tree.  Such transformations include edits that are suggested by a writing assistance tool <cit.>, or subtree deletions in compressive summarization <cit.>.

For our experiment, we evaluate an interesting case of syntactic transformation. <cit.> consider a systematic rephrasing procedure by rearranging the order of dependent subtrees within a UD treebank, in order to synthesize new languages with different word order that can then be used to help train multi-lingual systems (i.e., data augmentation with synthetic data).

As  acknowledge (), their permutations treat surface punctuation tokens like ordinary words, which can result in synthetic sentences whose punctuation is quite unlike that of real languages. 




In our experiment, we use wang-eisner-2016 “self-permutation” setting, where the dependents of each noun and verb are stochastically reordered, but according to a dependent ordering model that has been trained on the same language.  For example, rephrasing a English sentence under an English ordering model may yield 
 which is still grammatical except that , and . are wrongly swapped (after all, they have the same POS tag and relation type).
Worse, permutation may yield bizarre punctuation such as , , at the start of a sentence.




Our punctuation model gives a straightforward remedy—instead of permuting the tree directly, we first discover its most likely underlying tree 
 by the maximizing variant of <ref>  (<ref>). Then, we permute the underlying tree and sample the surface punctuation from the distribution modeled by the trained PFST,
yielding 

We leave the handling of capitalization to future work.

We test the naturalness of the permuted sentences by asking how well a word trigram language model trained on them could predict the original sentences.[So the two approaches to permutation yield different training data, but are compared fairly on the same test data.
]
As shown in <ref>, our permutation approach reduces the perplexity over the baseline on 4 of the 5 languages, often dramatically.





§ RELATED WORK


Punctuation can aid syntactic analysis, since it signals phrase boundaries and sentence structure.
<cit.> and <cit.>
parse punctuated sentences using hand-crafted constraint-based grammars that implement Nunberg's approach in a declarative way.  These grammars treat surface punctuation symbols as ordinary words, but annotate the nonterminal categories so as to effectively keep track of the underlying punctuation.  This is tantamount to crafting a grammar for underlyingly punctuated sentences and composing it with a finite-state noisy channel.  

The parser of <cit.> takes a different approach and treats punctuation marks as features of their neighboring words.  <cit.> use a generative model for punctuated sentences, leting them restore punctuation marks during transition-based parsing of unpunctuated sentences. <cit.> use punctuation marks to segment a sentence: this "divide and rule" strategy reduces ambiguity in parsing of long Chinese sentences.  Punctuation can similarly be used to constrain syntactic structure during grammar induction <cit.>.  Punctuation has been used to remove redundant treebank rules, yielding cleaner training data <cit.>.

Punctuation restoration (<ref>) is useful for transcribing text from unpunctuated speech. The task is usually treated by tagging each slot with zero or more punctuation tokens, using a traditional sequence labeling method: conditional random fields <cit.>, recurrent neural networks <cit.>, or transition-based systems <cit.>. 



§ CONCLUSION AND FUTURE WORK



We have provided a new computational approach to modeling punctuation.  In our model, syntactic constituents stochastically generate latent underlying left and right punctemes.  Surface punctuation marks are not directly attached to the syntax tree, but are generated from sequences of adjacent punctemes by a (stochastic) finite-state string rewriting process  .
Our model is inspired by nunberg1990linguistics formal grammar for English punctuation, but is probabilistic and trainable.  We give exact algorithms for training and inference.

We trained Nunberg-like models for 5 languages and L2 English. We compared the English model to Nunberg's, and showed how the trained models can be used across languages for punctuation restoration, correction, and adjustment.

In the future, we would like to study the usefulness of the recovered underlying trees on tasks such as syntactically sensitive sentiment analysis <cit.>, machine translation <cit.>, relation extraction <cit.>, and coreference resolution <cit.>. We would also like to investigate how underlying punctuation could aid parsing. For discriminative parsing, features for scoring the tree could refer to the underlying punctuation, not just the surface punctuation. For generative parsing (<ref>), we could follow the scheme in <ref>.
For example, the  factor in <ref> might be a standard recurrent neural network grammar (RNNG) <cit.>; when a subtree of  is completed by the Reduce operation of , the punctuation-augmented RNNG (<ref>) would stochastically attach subtree-external left and right punctemes with p_ and transduce the subtree-internal slots with p_.

In the future, we are also interested in enriching the  representation and making it more different from , to underlyingly account for other phenomena in  such as capitalization, spacing, morphology, and non-projectivity (via reordering).



§ ACKNOWLEDGMENTS
 
This material is based upon work supported by the National Science Foundation under Grant Nos. 1423276 and 1718846, including a REU supplement to the first author.  We are grateful to the state of Maryland for the Maryland Advanced Research Computing Center, a crucial resource. We thank Xiaochen Li for early discussion, Argo lab members for further discussion, and the three reviewers for quality comments.


acl_natbib

empty



§ FEATURE TEMPLATES FOR 



Below, we provide feature templates for the features used by the Attach model in <ref>.  To illustrate, <ref> lists all the non-backoff features that fire on a particular node in <ref> of the main paper.  Specifically, <ref> lists the nonzero features in the feature vector (,,) where  is the tree node that dominates the subject  and (,)=(,) says to surround that subject with quotation marks.

In general, the feature vector (,,) assigns nonzero values (1 values unless otherwise stated) to the features that are named by the following tuples.  (We use dots here to separate the elements of a tuple.)


    
  * ...., ...., ..., ..., and ..., where  is the POS-tag of the word at ,  is the dependency relation that labels the edge of  that points to , and = or  according to the direction of that edge.  The first feature name is most specific, while the remaining 4 features are backoff features.

      For example, such features can be used to say that an appositive (d=appos) headed by a noun (g=NOUN) likes to be surrounded by commas (==,).

      To make training faster and perhaps avoid local optima, we initialize the weight of feature .l.r.d to its log-count in training data.

    
  * .h...., .h...., .h..., .h..., and .h..., where h measures the length of the constituent headed by : h=1 for a short constituent (1–2 words), h=2 for a medium constituent (3–5 words), and h=3 for a long constituent (≥ 6 words).

      For example, a positive weight on .3.,.,.advcl says that long subordinate clauses (h=3, d=advcl) are likely to be surrounded by commas.


  * .....', .....', ....', ....', and ....', for each dependency relation ' that occurs along the path from the root of  to the parent of .  (Here ,, and  are properties of  as before, whereas ' refers to an ancestor of .)  The value of this feature is the number of times that ' appears along the path.  Notice that if =root, the path is empty, so none of the  features fire.

  For example, such features might cause a subordinate clause to be punctuated differently depending on whether it is attached to the main verb or a more deeply nested verb.


  * .....', .....', ....', ....', and ....', for each 
  dependency relation ' that appears on an edge from  to a child of .  The value of this feature is the number of such edges.  Notice that if  is a leaf, it has no children, so none of the  features fire.

  For example, such features could be used to say that a relative clause that contains a subject ('=subj), such as an object-relative clause, likes to be surrounded by commas.


  * .._-1._+1 and .._-1._+1, where _-1 and _+1 are the POS-tags surrounding the slot where  or  (respectively) is generated.  We use _-1= or _+1= if the slot is at the beginning or the end of the sentence (respectively).


  * .., .., ., . and ., provided that  and  are symmetric punctemes.  Symmetry is determined by simultaneously scanning  from left to right and  from right to left, and checking whether the punctuation marks at each position form one of the following pairs:[A more complete list could be compiled from Unicode's opening/closing punctuation pairs, but this list is sufficient for the experiments in this paper.] .  If l and r are both empty strings, they are not considered symmetric.


  * c...., c...., c..., c... and c..., for each punctuation token c that appears at least once as surface punctuation within the constituent dominated by .  (That is, if 's constituent stretches from slot i to slot k, its internal slots are j = i+1,…,k-1, and c must appear in _j for some such j.)

  These features make it possible to implement punctuation marks of different precedence.  For example, a conjunct is ordinarily delimited by commas (<ref>), but a conjunct that already contains internal commas (c=,) may be delimited by semicolons instead, as shown below.[Unfortunately, this feature does not explain why all other conjuncts in the same conjunction (including the final conjunct) also switch to semicolons.]  Similarly, an appositive that already contains internal commas may be delimited by dashes instead of commas.
  
    There are two ways to read newspapers: 
      in print, which is costly; 
        or in digital, which is free.
  



Some of these features are not edge-local.  They look at entire paths or constituents, or the surface punctuation of a constituent.  However, they do admit tractable exact algorithms, similarly to a neural HMM <cit.>.  How?

During training, <ref> of <ref> is able to compute each feature vector (,,) given the observed input tree  and surface punctuation .  

<ref> and <ref> both need to find the 1-best underlying tree  that corresponds to the given  and  of a treebank sentence, so that it can correct or permute that sentence.  As discussed at the end of <ref>, this makes use of the same feature vectors (,,), and merely replaces the inside algorithm with a Viterbi decoding algorithm.

The situation is slightly more difficult at test time, when  is still observed, but the surface punctuation is not observed and must be sampled (<ref>).  However, we can still do exact joint sampling of  and  by traversing  bottom-up.  That is, after we have processed the child nodes of , we can process  by sampling _j at the internal slots between its children (using ) and then sampling (ℓ,r) at its external slots (using , which may depend on the _j values via the c features).  






§ POSTERIOR REGULARIZATION



<Ref> includes the expectation of c(), which counts the nodes in  whose l and r punctemes contain any unmatched punctuation tokens.

We define a criterion to decide whether l and r are unmatched, based on this list of matched symmetric tokens: .  This is the same list used by the  feature in <ref>, except that it omits the pairs where the two tokens are equal (namely  and ).

First, we modify l and r to filter out tokens that do not appear in the list above.  We then check whether the modified l and r are symmetric punctemes in the sense of the  feature (<ref>).  If not, we count the node as having unmatched punctuation.



§ CORRECTION FEATURE TEMPLATES



For the correction model (<ref>), recall that we first find the 1-best underlyingly punctuated tree _e that explains a tree  along with its possibly erroneous or non-standard surface punctuation _e.  

We then use  to generate corrected punctuation to attach to  .  At this step, it may be beneficial to condition on knowledge of the reconstructed underlying punctuation that we reconstructed in _e.  Thus, we add the following 2 feature templates, which are extended versions of the  and  features in <ref>.
In these templates for evaluating (,,) in a proposed , ' and ' denote the left and right underlying punctemes attached to the corresponding node _e in _e.



  * .....'.', ....'.', ....'.', ...'.'

  * .h.....'.',.h....'.', .h....'.',
.h...'.'




§ PFST IMPLEMENTATION




  
Construct the PFST

sarrow








Recall from <ref> that our noisy channel is supposed to slide a 2-token window over the string of punctuation tokens, stochastically editing them as it goes.  

In our PFST implementation, each arc has the form ab:cd, which transitions from state a to state d while reading an underlying punctuation token b and generating a surface punctuation token c.  Here the state label a represents the first token in the current sliding window, and the underlying token b provides the second token in that window.  All surface tokens preceding a have already been output by the PFST.  a has not yet been output by the PFST, because it will not necessarily be part of the surface string—it might still be deleted or transposed.

Choosing to traverse this arc corresponds to choosing a particular edit to the current window contents ab.  After this edit, the new state d will reflect the first token in the new position of the sliding window.[Specifically, the new window contents will be de, where e is the underlying token e that follows b.  That token e will be read by the next arc—the arc taken from the new state d.]

Recall from <ref> that there are 4 possible edits to ab.  These correspond to different choices of c and d in ab:cd:


  * To allow ab ↦ ab (no change), we include an arc with c=a and d=b.  This outputs the delayed token a, and then slides the window rightward so that b is now the first token.

  * To allow ab ↦ b (left absorption), we include an arc with c=ϵ and d=b.  This is identical to the previous case, except that it chooses to skip outputting a, so a has been deleted.

  * To allow ab ↦ a (right absorption), we include an arc with c=ϵ and d=a.  This is identical to the previous case, except that it is now b that it skips outputting.  The first token in the sliding window therefore remains a.

  * To allow ab ↦ ba (transposition), we include an arc with c=b and d=a.  This is identical to the previous case, except that it outputs b before the delayed token a.  We still have not output a, so 
  the first token in the sliding window remains a.

The probabilities of these 4 arcs are specified by the noisy channel parameters .  They must sum to 1 because our noisy channel model will choose exactly one of the 4 edits for the current sliding window ab.  This fact helps to ensure that our automaton is indeed a PFST, whose definition requires that the possible transitions from a given state a on a given input token b must have total probability of 1 <cit.>.

We must also deal with boundary conditions, using boundary tokens  and  at the start and end (respectively) of the underlying string.  


  * The PFST starts in the special state , meaning that the sliding window is before the left edge of the string.  The arcs from  have the form a:ϵa (with probability 1), which effectively edits the boundary window a by left absorption of the .  
  In effect, taking the arc simply slides the window rightward to the first “real” position of the sliding window, discovering that its first character will be the first underlying token a.

  * We append the terminal token  to the underlying string.[In contrast, we did not prepend the initial token  to the underlying string, but rather initialized in a state  that pretended that  had previously been read.]
  Thus, the sliding window's final position has the form a.  The arcs that consume this token have the form a:a (with probability 1), which effectively edits the boundary window a by right absorption of the , but with the modification that it actually emits the delayed character a (which cannot undergo any further changes) and halts.


Let  be the vocabulary of punctuation types; our PFST  has ||+2 states. There is a start state  , a final state , and the remaining || states each represents a punctuation type. 
An edge sa:bt denotes a transition from state s to t upon reading an underlying punctuation token a and generating a surface punctuation token b. The weight of this edge is the probability of such a transtion, which is 

The set of edges in our PFST could be enumerated as follows:


  * ab:ba,ab:ϵb,ab:ϵa,ab:ab , for all distinct a, b∈ 

  * a:ϵa,a:a,aa:ϵa,aa:aa , for all a∈

  * :ϵ (same as the first case above but where a= instead of a ∈Σ)

<Ref> illustrates the topology of our PFST with a toy vocabulary = {a, b}. The PFST is locally normalized, because the weights of edges from a given state on the same input sum up to 1.  (See <cit.> for a full discussion of locally normalized PFSTs.)



  
From PFST to WFSA
In <ref>, we construct a weighted finite-state acceptor (WFSA) for each slot, which describes all possible underlying strings u_i that can be rewritten as the surface string x_i that was observed in that slot. We will explain how to obtain this WFSA.  The method is a detailed explanation of <ref> in <ref>, already sketched in <ref>.

First, we construct the composition , where  is the PFST as shown in yellow in <ref>.  This composition extracts just the paths of  that would output the given surface string _i.  To perform this composition, we must represent the string x_i as an unweighted straight-line FSA with one arc per token of _i.  We show this FSA in green: _i[1]1_i[2]2⋯_i[||]||.  

The composition  is illustrated in <ref>. Each state in the composition has the form y,z, where y is some yellow state identifier in  and z is some green state identifier in the straight-line FSA for _i.   Thus, we depict it in <ref> as a yellow/green state.
In other words, the state space of  consists of the Cartesian product of the PFST states and the straight-line FSA states.
The edge y,zsy',z' exists if and only if  ys:ty' exists in  and ztz' exists in , with the edge weight inherited from the former.
Note that the result of composition is a WFST rather than a PFST, since the arc weights are no longer guaranteed to be locally normalized.

Finally, to obtain the desired WFSA that describes the possible underlying strings _i that could have yielded _i, we project the WFST onto its domain (input).  This is a simple matter of dropping the output (which follows the colon) from each arc in the WFST of <ref>.  The weights are retained.




