1 Introduction
We present a simple and intuitive unsound corpus-driven approximation method for turning unification-based grammars (UBGs), such as HPSG (Pollard and Sag Reference Pollard and Sag1994), CLE (Alshawi Reference Alshawi1992), or PATR-II (Shieber, Uszkoreit, Pereira, Robinson and Tyson Reference Shieber, Uszkoreit, Pereira, Robinson, Tyson, Grosz and Stickel1983), into context-free grammars (CFGs). The method is unsound (Pereira and Wright Reference Pereira and Wright1991) in that it does not generate a CFG whose language is a true superset of the language accepted by the original unification-based grammar. It is a corpus-driven method in that it relies on a corpus of parsed sentences and generates broader CFGs when given more input samples. Our open approach can be fine-tuned in different directions, allowing us to monotonically come close to the original parse trees by shifting more information into the context-free symbols. The approach has been fully implemented in JAVA. This article updates and extends the paper presented at the International Colloquium on Grammatical Inference ICGI 2004 (Krieger Reference Krieger, Paliouras and Sakakibara2004) and presents further measurements.
1.1 Motivation
The motivation for developing this corpus-based approximation method was manifold.
Two-Step Parsing. An approximated CFG can be seen as a cheap recognition pre-flter during NL parsing with a worst-case running time of 0(n 3) for a sentence of length n, whereas UBG parsing usually comes up with an exponential worst-case complexity. Given the existence of such a pre-flter, a unification-based parser thus only needs to deterministically replay the CF parse trees afterwards, i.e., must not fully explore its search space during all-path parsing (Kiefer and Krieger Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002; Kiefer and Krieger Reference Kiefer, Krieger, Bunt, Carroll and Satta2004). UBG tree reconstruction is easily established by a total many-to-one mapping (a surjective function) from CFG rules onto UBG rules.
Disambiguation of UBGs. By moving from the approximated CFG and a training corpus to a PCFG that predicts probabilities for CF parse trees, we also obtain an indirect and efficient stochastic parsing model for the UBG, even though the UBG might encode an infinite number of categories. I.e., we shift the responsibility for predicting the ‘right’ derivation trees to the context-free side, where mathematically clean methods exist. Using the probabilities, we can dynamically rank the CF parse trees at runtime, and again, let the UBG parser deterministically replay these trees. This establishes an order on the UBG trees that can be employed for UBG disambiguation (Kiefer, Krieger and Prescher 2002).
Domain-Specific Subgrammars. The extraction of useful domain-specific context-free subgrammars from general-purpose unification-based grammars is an important topic in information extraction and question answering (Neumann Reference Neumann, Bod, Scha and Simaan2003). Our approach thus may obviate the laboriously manual construction of such domain-specific grammars. As we will see later, our method neither produces a superset nor a subset of the language generated by the original UBG. However, this is a desired effect, since a domain-specific subgrammar is not intended to generate a true superset: it should cover the relevant constructions of the domain and only these constructions (in the best case). And because it is also not a true subset of the UBG, it can be robust against ungrammatical input w.r.t. the domain we are interested in.
Context-Free Language Models. Given an UBG, it would be nice to have an automated compilation method that yields a CFG which in turn serves as a symbolic, word-based (instead of phoneme-based) context-free language model, guiding a speech recognizer (Rayner, Dowding and Hockey Reference Rayner, Dowding and Hockey2001a). This strategy obviates the sparse data problem in (commercial) recognizers, since we can directly operate on the high-level grammar without collecting and constructing large amounts of annotated speech training material (Wizard of Oz). The automatic compilation of a CFG from an UBG also makes a tedious hand-coded formulation of a CFG (or a regular grammar) superfuous (Dowding, Hockey, Gawron and Culy 2001). Findings in Rayner, Gorrell, Hockey, Dowding and Boye (2001b) suggest that agreement constraints in context-free language models improve the performance of a recognizer in terms of both word error rate and semantic error rate. Keeping the agreement constraints of the UBG in the CFG is easy in our approximation method. Finally, CF-based models clearly benefit from their greater expressive power when compared to regular models. It is worth noting that within the last four years or so, the commercial speech community has focused primarily on the grammar-based approach (VoiceXML, W3C, Nuance, Speech Works, etc.); see also Rayner et al (Reference Rayner, Dowding and Hockey2001a).
Open Approach. The adjusting parameters of our approach make it easy to approximate CFGs of different size and quality, e.g., by varying the annotations of context-free symbols, by collecting the approximated CF rules either under rule equivalence or under rule subsumption, or by taking a larger domain of locality into account, by using the feature structures of the UBG, resulting in various forms of context-free tree grammars. Even though these tree grammars are still context-free, they clearly have a larger event horizon, establishing a restricted form of look-ahead.
1.2 General Idea
Since unification-based parsers usually rely on a context-free backbone of unification rules (or rule schemata, to borrow the broader HPSG term), it should not be that difficult to extract a context-free grammar. In fact, relatively specific unification-based rules, for instance, in ANLT (Carroll, Briscoe and Grover (Reference Carroll, Briscoe and Grover1991) or LFG (Kaplan and Bresnan Reference Kaplan, Bresnan and Bresnan1982)), should result in approximated CFGs of good quality (cf. Carroll (Reference Carroll1993) and section 4 for a discussion of other approaches). However, lexicalized grammar theories such as HPSG, or even categorial grammar frameworks, like CUG (Uszkoreit Reference Uszkoreit1986) or UCG (Zeevat, Klein and Calder Reference Zeevat, Klein, Calder, Haddock, Klein and Merrill1987), are of a different kind: rule schemata in these frameworks are usually so general that the resulting CFGs are worthless, meaning that they accept nearly everything (Briscoe and Carroll Reference Briscoe and Carroll1993). Proper recognition of utterances in lexicalized theories is realized by shifting the great amount of information into the lexicon and by applying a specific descriptive means in rule schemata: coreferences or reentrancies.
Our attempt thus does not operate on the rules of a unification-based grammar – as do (Kiefer and Krieger Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002) in their sound HPSG approximation -but instead on valid rule instantiations of a special kind, viz., passive edges of the unification chart, resulting from parsing a corpus. In order to access such passive edges, we have defined an external exchange format for representing a chart (see section 3.1). Since passive edges directly encode their immediate daughters, a passive edge can be seen as a tree of depth 1. From such a tree and with the help of the feature structure directly associated with each passive edge, it is possible to create an annotated context-free rule of arbitrary specificity (section 3). Terminal and nonterminal symbols in our framework are equipped with information from the related feature structure of the passive edge, similar to annotated symbols in the GPSG framework (Gazdar, Klein, Pullum and Sag Reference Gazdar, Klein, Pullum and Sag1985) (see section 2.1). When taking deeper nested daughters into account, we can even escape the flat domain of context-free rules, resulting in CF tree grammars.
1.3 Structure of the article
The structure of this article is as follows. In the next section, we first discuss the objects which are constructed and manipulated during the extraction of the CFG (symbols, rules, edges). After that, section 3 presents the interface to the chart of the HPSG parser and describes the basic extraction algorithm, together with a variation which produces smaller, although more general CFGs. The section also has a few words on the quick-check paths of the UBG which serve as the starting point for finding the proper annotations of the context-free symbols. Section 4 then comes with a discussion of other approaches which aim at extracting a CFG from an UBG, most of them unsound. In section 5, we elaborate on further aspects of the extraction methods, discussing several orthogonal adjusting parameters which result in different CFGs, given a UBG. We also discuss additional postprocessing steps and motivate that the extracted CFGs can be tuned to deliver a meaningful semantic output as well. After that, section 6 applies our method to the large English Resource Grammar, developed at CSLI, Stanford, including a small evaluation w.r.t. to a 10% hold-out sample set. Finally, section 7 indicates our next steps.
2 Objects of Interest
The goal of this section is a description of the implemented objects which are built and manipulated by the extraction algorithm (section 3). The section furthermore defines certain important relations between symbols and rules. We assume a basic familarity with typed feature structures (TFSs) here (Carpenter Reference Carpenter1992), and refer to the set of all types by
. By type subsumption we mean the decidable partial order
.
2.1 Symbols
Terminal and nonterminal symbols of the context-free grammar are represented as instances of the JAVA class Symbol.Footnote 1 Symbols bear a name field of type String and an annotation field of type int [] (an integer array). The name field of a terminal refers to the full surface string of this terminal word and its annotation field is empty (refers to the null value). A nonterminal also has a name and encodes the HPSG rule name (e.g., hcomp or measure_np). The annotation of a nonterminal symbol groups several type identifers which originate from (possibly deep-nested) values under pre-specified paths (the so-called annotation paths) within the instantiated rule TFS for this nonterminal symbol. Thus an annotation is quite similar to a feature specification in GPSG (Gazdar et al. Reference Gazdar, Klein, Pullum and Sag1985) or a quick-check vector (Kiefer, Krieger, Spilker and Weber 1996; Malouf, Carroll and Copestake Reference Malouf, Carroll and Copestake2000).
During the more formal parts of this article, we need two fundamental concepts: symbol and annotation.
Definition 1 (SYMBOL)
We refer to a symbol s in the abstract syntax by a pair 〈n, a〉, consisting of name n and an annotation a. We write N(s) to depict the first projection of s (the name) and A(s) to access the annotation part of s. When using concrete syntax, we write a symbol in the more GPSGish notation n [a].
Definition 2 (ANNOTATION)
An annotation a = 〈t. . ., t n〉 is a n-tuple of type names or type IDs t i ε
, i ε{1,. . .,n}. We write πi(a) to denote value t i of the i-th projection of a. Using the GPSG-like concrete syntax, we write [t 1,. . .,t n] to depict annotation a.
Given two symbols, we define a subsumption relation ≼ which turns out to be useful in a moment.
Definition 3 (SYMBOL SUBSUMPTION)
Let s 1 and s 2 be two annotated context-free symbols, s 1 is said to be subsumed by s 2 (written as s 1 ≼ s 2) iff N(s 1) = N(s 2) N(s 2) and πi(A(s 1)) ≼ πi,((s 2)), for all i ε {1,. . .,n}. Alternatively, we say that s 2 subsumes (or is more general than) s 1. Assuming that s 1 and s 2 are terminal symbols, their annotation must be empty (A(s 1) = A(s 2) = 〈 〉), thus the second condition above is trivially satisfed.Footnote 2
Let us give an example. Assume we have the four CF symbols (concrete syntax) N[sg, fem], N [pl, fem], N[num, fem], D[num, fem] and assume that sg ≼ num and pl ≼ num is the case. We can then infer that N[sg, fem] ≼ N [num, fem] and N [pl, fem] ≼ N[num, fem] holds. However, N[sg, fem] and N[pl, fem] are not related by the subsumption relation. Consequently, we say that these symbols are incomparable and use the ⋈ sign to indicate this: N[sg, fem] ⋈ N [pl, fem]. Furthermore, D [num, fem] is incomparable with every other symbol, due to its name: D ¬ N.
2.2 Rules
We represent context-free grammar rules by the class Rule whose instances have a left-hand side (lhs) and a right-hand side (rhs) field. The left-hand side is (from a CFG point of view) a nonterminal symbol, which we represent as an instance of the class Symbol. The right hand-side is an array of Symbol objects (JAVA notation: Symbol []). The length of rhs is encoded in an additional field length of type int. A Rule object also possesses a frequency field, telling us how often that rule has been applied during parsing of a given corpus. It is worth noting that the frequency counter might gain importance when we move from the extracted CFG to a PCFG which will predicts probabilities for CFG trees.
Next, we need the formal notation of a grammar rule.
Definition 4 (CONTEXT-FREE GRAMMAR RULE)
Let l, r 1,. . .,rn be (annotated) context-free symbols and let furthermore l be a nonterminal symbol. We then call the expression l → r 1. . .rn a context-free grammar rule. l is usually referred to as the left-hand side (LHS) of the rule, whereas the sequence r 1. . .r n is called the right-hand side (RHS). Given a CF rule α, the projection L yields the LHS of α, i.e., L(α) = l. R delivers the RHS: R(α) = r 1. . . rn.
Given the above apparatus, defiling a subsumption relation ≼ on rules is relatively straightforward.
Definition 5 (RULE SUBSUMPTION)
Let α = (l α → r 1α. . .rnα) and β = (l β → r 1β. . .rnβ) be two context-free grammar rules. We say that α is subsumed by β and write α ≼ β iff l α ≼ l β, n α = n β, and riα ≼ r iβ; for all 1 ≤ i ≤ n α. Alternatively, we say that β subsumes (or is more general than) α.
We say that two CF rules α and β are equivalent iff they both subsume each other: α ≡ β : ⇔ α ≼ β and β ≼ α.
Let α ⋠ β abbreviate ¬(α ≼ β). Two rules are said to be incomparable iff they are not related by rule subsumption: α ⋈ β:⇔ α ⋠ β and β ⋠ α.
An example. Given the symbols from the example at the end of subsection 2.1, we defiie a subsumption order over the following three rules (we use again the concrete syntax in which the implemented algorithm delivers the rules). Let α = (NP[sg, fem] -> N[sg, fem]), β = (NP[pl,fem] -> N[pl, fem]), and γ = (NP[num, fem] -> N[num, fem]). Then α ≼ γ and β ≼ γ, however α ⋈ β.
2.3 Edges
The edges which are transmitted by the HPSG parser in plain text (see figure 1) are reconstructed in main memory within the JAVA virtual machine. At the moment, we are using a modifcation of the freely available PET parser (Callmeier Reference Callmeier2000). The set of all passive edges for a single parsed sentence are grouped in a text file (see next section).
Edges are represented as instances of the JAVA class Edge, consisting of the instance fields id, ruleName, immDtrs, noOfDtrs, and annotation. The id of an edge is a handle to the edge object and allows other edges to refer to this edge in their immediate daughters array immDtrs. id is of type int, thus immDtrs must be of type int []. The string in the ruleName field of the edge leads to the primary category symbol of the LHS of the context-free rule later. As already described, annotations are represented as int vectors. The extraction algorithm in the next section produces for each given edge exactly one context-free rule. Due to the ruleName field, we know the name of the UBG rule from which the edge has been derived. Exactly this information is utilized during the deterministic second phase of two-stage parsing.
3 Extracting a Context-Free Grammar
This section centers around the offline extraction of a context-free grammar from a given corpus, originally parsed by the deep HPSG parser of the PET system (Callmeier Reference Callmeier2000). We first describe the textual interface between our extraction component and PET. After this, we motivate that the annotation values of context-free symbols for a recognition grammar are related to the quick-check paths, originally introduced within the context of deep HPSG parsing (Kiefer et al. 1999). Given this background, we then describe the basic extraction algorithm in pseudo code. Finally, we argue for an extension of the original algorithm, which helps to compute smaller grammars and describe how the frequencies for the context-free rules are obtained.
3.1 Interface to HPSG
The interface to HPSG is established via the creation of text files: for every input sentence of the corpus, a new file is created that contains exactly the passive edges produced by PET. Although not every deep passive edge contributes to a deep reading, we have decided to take all passive edges into account (one can think of other options as well; see section 5). Since the passive edges of the deep parser are objects in main memory and since our extraction runs in a separate thread, we have defined an ASCII-based exchange format for chart edges that is given by the EBNF in figure 1. Figure 2 then displays the stripped-down chart for the sentence Kim loves Sandy. Due to the fact that features and types are represented as integers in PET, it is important that both PET and the extraction process operate on the same
(Krieger and Schafer Reference Krieger and Schafer1994) grammar.
The external exchange format of a chart as delivered by a modifbd version of the PET system. The meta characters and express optionality, | enforces the choice of exactly one alternative, and * and + refer to Kleene star and Kleene plus, resp. integer denotes the set of all integers, i.e., sequences of numeric decimal characters, string denotes the set of all strings, i.e., sequences of plain text characters, enclosed by double quotes. Note that each chart edge must be separated by the newline character <CR> at the end. At the moment, we do not benefit from the start and end position of an edge, rulename serves as the main category symbol, imdtrs refers to the immediate daughters of an edge. Since the delivered passive edges are topologically sorted, it is not necessary to reencode an edge that has already been introduced earlier. Thus the immediate daughters imdtrs of an edge are referred to by integer numbers id. The only exception are terminal symbols (the surface form) which are written as pure strings.
Parts of the chart for the sentence Kim loves Sandy. Note that the chart is topologically sorted, i.e., it is guaranteed that edge ids are introduced before they are referred to in the immediate daughters list. For instance, edge 13 refers to edge 11 (i.e., originating from a unary rule), edge 30 to edges 17 and 28 (a binary rule), etc. The edges 1–11 can be thought of as realizing the lexicon lookup. Notice that loves is assigned nine readings (different senses & morphosyntactic variations). The unary rules 12, 13, 15, 19, and 22 are morpholexical rules. The unary rule proper_np (17, 18) raises a noun to an NP. Some passive edges (40–42) result in useless CF rules for this sentence, since they represent dead branches in the search space.
Because HPSG requires all relevant information to be contained in the synsem feature of the mother structure, the unnecessary daughters (which are part of the TFS) only increase the size of the overall feature structure without constraining the search space. Due to the Locality Principle of HPSG (Pollard and Sag Reference Pollard and Sag1987), they can therefore be legally removed in fully instantiated items, i.e., passive edges which are delivered by the PET parser. To be independent from a certain grammatical theory or implementation, we use restrictors similar to Shieber (Reference Shieber1985) as a fbxible and easy-to-use specification to perform this deletion. In case we are trying to work with a larger tree context and not limiting ourselves to context-free rules (= trees of depth 1), the restrictor is the right means to accomplish this (see section 5).
3.2 Quick-check paths
Quick-check paths (QC) are used during unifbation-based parsing to quickly and correctly filter out failing unifications without applying the more costly unification operation (Kiefer et al. 1999; Malouf et al. Reference Malouf, Carroll and Copestake2000). Such a filter is extremely important since most of the unifications usually fail (95–99% of all unifications). The quick-check filter exploits the fact that unification fails more often at certain points in feature structures than at others. In order to determine the most prominent failure points, we parse a large test corpus in an offline stage (to be precise, we use a part of the corpus from which we extract the CFG), using a special unification engine that records all failures instead of exiting after the first failing unification.Footnote 3 These failure points, more exactly, the types of the feature structures at these points, constitute the quick-check (QC) vector. When executing unification during parsing, those points are efficiently accessed and checked using type unification prior to the rest of the structure. QC filtering heavily relies on type unification being very fast, which in fact is the case since it can be cached or even precompiled (Kiefer et al. Reference Kiefer, Krieger, Carroll and Malouf1999; Kiefer, Krieger and Nederhof Reference Nederhof2000). Figure 3 displays the ten most prominent failure paths for a specific corpus we have used in our experiments (cf. section 6).
The ten most prominent failure points for the English HPSG grammar (June 2002) in decreasing order.
As already said in section 2.1, the annotation of a context-free symbol bears a close resemblance to a QC vector – an annotation is a subvector of a QC vector., i.e., we might not take all vector positions into account. The reason for using (parts of) the QC vector as an annotation is due to the fact that we are interested in fast and modestly overgenerating context-free recognition grammars. Exactly the failure points in a QC vector are of this property, viz., heavily contributing to failures which rule out parts of the search space during unification-based parsing.
We note here that not every QC path has to be present in every feature structure, since only certain features are appropriate for certain TFSs. Let us give an example. Given the above set of QC paths, it turns out that the original head-complement rule hcomp is undefined for the ninth QC path. To account for this problem, we introduce a type U to express such undefnedness. U clearly only unites with the most general type T, and of course with itself. Using concrete syntax, we write *undef *. Consequently, we obtained instantiations of the binary head-complement rule schema hcomp, schema 1 in Pollard and Sag (Reference Pollard and Sag1994), such as
To circumvent such undef values, it might be a good idea to work with different annotation vectors for each primary category symbol. This means that we have to partition the set of rule names R = R 1 U . . . R n, such that each. R i (1 < i < n) is associated with a set of defined quick-check paths. We have not tried this strategy yet.
3.3 Algorithm
The idea behind the context-free extraction is relatively straightforward and is given in pseudo code in Figure 4.
The overall structure of the extraction algorithm.
As we already said, the HPSG parser produces for each input sentence an output file that contains an external representation of the passive edges of the chart for this sentence, encoded in the format given by Figure 1. The extraction HPSG2CFG then works as follows. Given a directory D and a vector of quick check paths Q, we iterate over the files in D (line 3). For each file, we then construct a vector edges of internal edges (i.e., JAVA objects) for the set of external passive edges stored in this file, using makeEdges (line 4). This includes the in-memory reconstruction of the TFSs for the mother structures (the LHSs). For each vector position, i.e., for each edge e, we build up a LHS symbol (i.e., a pair, see section 2.1), consisting of a name field (via getName) and an annotation vector (via get Annotation), given the quick-check paths Q (line 7). The same is done for every RHS symbol, but since we usually have more than one RHS symbol, we collect them in a vector rhs of length equal to the number of the immediate daughters dtrs of the passive chart edge (lines 8–13). For every passive edge, we finally generate a context-free rule object (see section 2.2), given the LHS and the RHS (line 14). The new CF rules are adjoined to the result set (line 14). After we have processed all files in directory D, the result set is returned at last (line 17).
The subscript ≡ of the union operator in line 14 of the algorithm should indicate that new rules are added to the result set using rule equivalence. That is, a new rule only contributes to the final CFG if no structural equivalent rule has already been introduced earlier during the extraction process. Even for a small corpus, a large number of structural equivalent rules are generated, resulting either from reappearing words or from reappearing linguistic constructions. The non-astonishing observation is that the smaller the annotation gets, the larger the number of equivalent rules becomes. Clearly, by taking more quick-check paths into account, we obtain more specific CF grammars, consisting of more rules. In the next subsection, we will slightly modify line 14, replacing the rule equivalence test by rule subsumption.
3.4 A variation
Rule subsumption, defined in section 2.2, now comes into play to potentially scale down generated grammars. We apply this operation online during the extraction process in that we replace line 14 of the algorithm by
The intention behind ∪≼ is that a new rule is only added to the result set iff it is more general than at least one rule already in the set. If so, the old rule and perhaps further other rules are removed. If it is more specific, the new rule is clearly not added. The application of that operation guarantees that the rules from the result set result are pairwise incomparable, i.e.,
∪≼ is somewhat related to the specialized union operation ∪⊆ in Kiefer and Krieger (Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002). Whereas ∪⊆ operates over typed feature structures representing context-free symbols, our operation is directly applied to annotated CF rules.
Of course, ∪≼ does change the context-free language
when compared to the language
, resulting from the application of ∪≡:
Given the number of rules for the two grammars
and
, we have
A simple example clearly shows this. Assume that the temporary result set contains the following three CF rules
and assume that the new rule
subsumes both β1 and β2. ∪≼ would thus delete β1 and β2 from the result set and will add β to it. Furthermore, since B 1 and B 2 are no longer valid (β1 and β2 have been deleted!), we must replace every occurrence of B 1 and B2 by the new nonterminal B, introduced in production β. This, however, has the effect that at least the modifed rule (α′ = A ↦. . .B . . .), derived from a, overgenerates.
Our approach keeps track of such rule deletions by implementing a symbol subsumption maintenance graph. In the above example, we establish two associations between B 1, B 2 and B: (B 1 ↦ B), (B2 ↦ B). Given the example, it is possible that the new rule β might even be deleted by a newer, more general rule B′ → . . . later. In this case, we have to further specify a new association: (B ↦ B′).
In the end, such substitution chains will be dereferenced, so that we can immediately substitute a dead RHS symbol by its correct and existing LHS counterpart. In the example, for instance, we must then know that B should not be substituted by B, but instead by B′.
We also have to make associations for the converse case - if a new special rule y is not added due to an existing more general rule l we must record this fact by creating the association (L(y) ↦ L(y′)), since L(y) might occur on the RHS of final CF rules.
We note here that the substitutions are of course not restricted to the LHS symbols only. Consider the following three toy CF rules which we might have acquired so far
and assume that the new, more general rule β′
now comes in, substituting β. The result set then changes to
Since we substitute the dead symbols at the very end of the approximation, the resulting CFG is clearly not optimal, i.e., not minimal. A proper treatment here would require that we have to update the symbol substitution graph (and potentially perform substitutions) each time a new passive edge is checked against the temporary CF rule set. Since we might process several millions of edges during the approximation of a grammar, we do not apply this technique at the moment.
At this point of our investigation, we already note here that favoring rule subsumption does not have any significant advantage over rule equivalence (about 10% less rules only), but mostly disadvantages (complex handling of dead symbols and rule frequencies, worst running time and space consumption of the approximation, overgeneration). Our measurements in section 6 show that even for the largest English HPSG and for two different huge training corpora, the number of approximated CF rules under rule equivalence can still be handled by a properly implemented CF parser (less than 60,000 rules). It is worth mentioning that the closely related subsumption operation U⊑ in Kiefer and Krieger (Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002) was ultimately necessary to made their purely grammar-driven approximation tractable. Kiefer and Krieger noticed that the use of equivalence had led to a massive explosion of CF rules in their setting. We were pretty sure to obtain similar results, but luckily rule equivalence gave us the best results and is nevertheless tractable.Footnote 4 We still hope that practical UBGs exist which will take advantage of rule subsumption. One can easily imagine a synthetic unification grammar which result in a CFG under rule subsumption that has exponentially-less rules than another CFG, obtained under equivalence from the same UBG.
3.5 Computing start productions
One point in the algorithm is still missing, viz., the generation of start productions. We have decided to employ only a single synthetic start symbol s in our grammars. This symbol has to be fresh, i.e., for all symbols 〈n, a〉 of the extracted grammar, we demand that N(s) ≠ n. In the implementation, the user must specify a nonempty list of start (or root) types, types which subsume original rule definitions, and thus subsumes potential rule instantiations. These types specify wellformedness conditions that a feature structure must satisfy to be a legal utterance (e.g., empty subcategorization list). Now let T be the set of all start types, R the set of extracted CF rules so far, and s the new top-level start symbol.
In the English ERG/LinGO HPSG grammar developed at CSLI, sentential phrases are subsumed by the type root-strict, and thus a start symbol in the extracted CFG can be determined by checking whether the name of a LHS symbol is subsumed by this start type. Non-sentential saturated phrases in ERG (e.g., PPs and NPs) are characterized by root-phr, thus if we want fnd all saturated phrases in the approximated CFG, we have to declare these two types to be start types.
3.6 Rule frequency
As we said in section 2.2, rule objects possess a frequency field which will gain importance if we are interested in a simple PCFG model which predicts probability distributions over CFG derivations. Since the counter is updated during the approximation process, we obtain a very basic and indirect disambiguation of UBGs for free, exploiting the fact, that ranked CF trees can be deterministically replayed by a deep unification parser; see Kiefer et al. (Reference Kiefer, Krieger and Prescher2002).
Exactly the frequency counter is set to 1 during the initialization of a rule object and is incremented by 1 in case a structural equivalent rule has been detected.
Concerning the frequency field f of a new rule α that has replaced more specific rules α1. . .αn, we have
since the more general rule now acts as a representative for the deleted specialized rules. Assuming the contrary, the frequency counters of truly general rules αi (1 ≤ i ≤ n) are incremented by 1 when penalizing a:
Considering the unary start productions from section 3.5, the frequency counter of a start production s →l is set to the sum of the frequencies of those rules α € R, whose LHS is exactly l given the set of all CF rules R:
To obtain a proper probability distribution, we have to normalize the rule frequency counter in the standard way (Charniak Reference Charniak1993). Now let R(l) := {I → r i 1. . .r i n | i, n ε N} be the set of all extracted CF rules sharing the same LHS l, f(α) be the value of the frequency counter for rule α € R(l), and F(l): = Σα∈ R(l)f(α). We then compute the probability p(α) for a context-free rule α = l → r 1. . .r n as
which gives us
As we said above, by using the likelihood of a rule, we obtain a simple PCFG model for free. At this moment of writing, we have not tested its disambiguation capability, but it is very likely that it outperforms an oracle which randomly chooses a CF rule in case more than one rule is applicable. We want to make some further remarks here.
Firstly, such a model should usually take only complete HPSG derivations into account, i.e., only sets of deep passive edges which fully cover the input and which are true readings. But because we are very practically interested to have a robust CFG, we have decided for every passive edge of the deep parser.
Secondly, obtaining lexicalized PCFGs from the approximated CFGs is not hard, since we can easily stuff word-specific information into the context-free symbols (with the disadvantage of having more rules, of course).
Thirdly, as an extension of the last point, CFGs (and so PCFGs) in our setting can embody dependecies that go beyond the capabilities of hand-written and trained (P)CFGs, reminding us of N-gram models and extensions thereof. This is due to the fact that the deep passive edges in the unification parser capture (unbound) dependencies (SUBCAT, SLASH), so that specific instantiations of such constructions can show up in the annotated CF symbols of the rules of the approximated grammars (if this is desired).
Finally, it is clear that the above simple statistical model can be replaced by a more advanced model, using, e.g., the inside-outside algorithm for unsupervised training of PCFGs (Lari and Young Reference Lari and Young1990; Pereira and Schabes Reference Pereira and Schabes1992). Kiefer et al. (Reference Kiefer, Krieger and Prescher2002) have shown that the disambiguation quality of approximated grammars clearly benefit from such a treatment.Footnote 5
4 Other approaches
In this section, we present several other approaches to compilation and approximation, some of them sound (Pereira and Wright Reference Pereira and Wright1991), that is, the language generated by the resulting grammar is a superset of the language of the original grammar, others unsound.
Goldstein (Reference Goldstein1988) was the first who converted an HPSG to a CFG. Goldstein, however, made several simplifed assumptions: (i) English is context-free; (ii) the number of categories/feature structures is finite; (iii) complex CF (non)terminals are not allowed; (iv) in the early development stage of HPSG, no coreferences and types are used. However, rules are underspecified and lexicalization is already present. This version of HPSG is essentially a modifed GPSG. Since Goldstein did not address the (possible) accumulation of information (e.g., under SUBCAT, CONT, or DTRS), a restrictor is clearly not needed. Rule instantiation is realized through an active bottom-up parser, using the chart to represent the feature structures.
Carroll (Reference Carroll1993) reported in his PhD thesis on the extraction of CF grammars from unification-based grammars, written in the ANLT (Alvey Natural Language Tools) grammar formalism. Grammars in ANLT usually consist of several hundred of relatively specific GPSGish rules with features having only finitely many values. Categories (= sets of feature-value pairs) can be defined in ANLT, but are not explicitly arranged in a type hierarchy. A single ANLT unification rule is mapped one-to-one onto a CF rule by introducing atomic symbols on the CF side that abstract from categories in the ANLT grammar. To avoid subsumption over CF symbols, subsuming categories are mapped onto a representative that encodes the least upper bound, similar to our operation ∪≼. A related approach is described in Nakazawa (Reference Nakazawa, Cole, Green and Morgan1995).
Diagne, Kaspar and Krieger (1995) and Kasper and Krieger (Reference Kasper and Krieger1996) present a distributed parsing approach that is distinguished by the use of a very restricted HPSG whose derivation trees are reparsed deterministically (in fact, in parallel) by the original HPSG. The two parsers mutually restrict their search space, using a specialized protocol.
Kasper et al. (Reference Kasper, Krieger, Spilker and Weber1996) employ the same idea, but substitute the restricted HPSG through the (relatively specific) context-free backbone of an HPSG-like grammar. By using the pure backbone and a corpus, a PCFG is trained and used online in order to obtain the n-best paths of a word lattice. The collection of these paths constitutes the initial chart of the second parser that uses the HPSG essentially for semantic construction.
Neumann and Flickinger (Reference Neumann and Flickinger1999) and Neumann (Reference Neumann, Bod, Scha and Simaan2003) describe an approach that obtains a stochastic lexicalized tree grammar (SLTG) for a given corpus. The idea here is that the training corpus is parsed using an HPSG grammar and an HPSG parser, and derivation trees are iteratively decomposed top-down, resulting in nonterminal nonheaded subtrees, where the cutting points are marked for later substitution. SLTGs are processed by an LTAG-like parser in a two-step process, consisting of an initial all-path parsing phase, followed by the application of the relevant HPSG feature constraints. This idea is related to LFG parsing, but has the clear advantage that a larger tree context is involved (although SLTGs are of context-free power). Since the extraction process of the SLTG grammar works on the derivation trees of a tree bank, viz., tsdb (Oepen and Flickinger Reference Oepen and Flickinger1998), the node labels are relative coarse generalizations of the information embodied in the feature structures used during HPSG parsing. The vagueness or underspecification of the node labels, however, is partly compensated by the larger tree context. The approach furthermore applies two postprocessing techniques: a linguistically-motivated decomposition of trees and a specialization of node labels.
Moore (Reference Moore and Ponting1999) describes a compilation method that turns unification grammars with finitely-valued features into context-free grammars. The grammar, he reports on, is written in the core language engine formalism of SRI Cambridge, and consists of about 900 relatively specific phrasal rules. Moore only consider finitely-valued features. In order to avoid the combinatorial explosion of rules, Moore only instantiates those features in daughter categories that are constrained by the unification rule and considers only combinations of feature values by unifying active and passive edges, as in a bottom-up active chart parser. He also throws away useless rules. Moore's paper presents a new left recursion elimination algorithm, specifically tuned for the grammar formalism GSL of the Nuance speech recognizer (Nuance 2004), taking advantage of the fact that GSL allows regular expressions. Moore also considers various combinations of acoustic and symbolic information in a language model and is a great overview paper. In a certain sense, Moore's approach is the forerunner for Rayner et al. and Dowding et al., laying the foundations for the more sophisticated enumerative compilation techniques below. Moore's expansion technique will probably not work for lexicalized theories, such as HPSG.
Kiefer and Krieger (Reference Kiefer and Krieger2000, Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002, Reference Kiefer, Krieger, Bunt, Carroll and Satta2004) present a sound approximation method that turns unification-based grammars, such as HPSG or PATR-II into context-free grammars. The method does not rely on a corpus, but is purely grammar-driven. In an initial phase, the method generalizes the set of all lexicon entries, by abstracting from word-specific information. The abstraction is specified by means of a restrictor. After that, the grammar rules are instantiated by unification, using the abstracted lexicon entries and resulting in derivation trees of depth 1. A rule restrictor is applied to each resulting feature structure, removing all information contained only in the daughters of a rule. Additionally, the restriction gets rid of information that will either lead to infinite growth of the feature structures or that does not constrain the search space. The restricted feature structures (together with older ones) then serve as the basis for the next instantiation step. Again, this results in TFSs encoding a derivation, and again the TFSs are restricted. The iteration is proceeded until a fixpoint is reached, meaning that further iteration steps will not compute additional information. Given the TFSs from the fixpoint, it is then easy to generate context-free productions, using the full feature structures as symbols of the CFG. The speedup factor for the aged and eng2000 testsuites within a two-stage parsing architecture are between 1.7–2.7.
In Kiefer et al. (Reference Kiefer, Krieger and Prescher2002), an extension of the method is presented which easily allows the disambiguation of UBG readings, by indirectly relying on a trained PCFG, derived from the approximated CFG. Considering a random baseline of 72% for the exact match task, the method shows an increase of 16% (= 88% precision).
In Cancedda and Samuelsson (Reference Cancedda and Samuelsson2000), a corpus-based specialization method is introduced which directly operates on rules written in the LFG framework. Because the LFG formalism allows RHSs of grammar rules to consist of regular expressions (REs), the idea of this framework is to expand RHSs into RE-free sequences of symbols, guided by the training data. Although Kleene star and complementation in REs as well as specialized operators like shuffle may introduce spurious ambiguities, such simplifed rule instantiations clearly speed up parsing (up to a factor 6). The downside of this method is that one might lose coverage (about 13%). To compensate for the loss in coverage, a two-stage parsing architecture is proposed in which a second stage, consisting of the original grammar, is only invoked in case the first specialized parser failed. Even with this backup mechanism, a speedup between 1.8–2.7 was obtained.
Dowding et al. (Reference Dowding, Hockey, Gawron and Culy2001) compare the approach to grammar approximation in (Moore Reference Moore and Ponting1999) to that in Kiefer and Krieger (Reference Kiefer and Krieger2000). As a basis for the comparison, they choose a command-and-control grammar written in the Gemini/CLE formalism. The motivation for this enterprise comes from the use of the resulting CFG as a context-free language model for the Nuance speech recognizer (Nuance 2004). The measurements in (Dowding et al. 2001) differ from those later conducted in Kiefer and Krieger (Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002, Reference Kiefer, Krieger, Bunt, Carroll and Satta2004). Unfortunately, it is not clear why Dowding's implementation of Kiefer and Krieger's method comes off so badly. Dowding report on an average ambiguity per sentence of 15.4, whereas Kiefer and Krieger comes up with only 1.49 (ambiguity rate for the original grammar was 1.44). The compilation time to obtain the approximated grammars differs too: 11 minutes vs. 34 seconds. With a slightly different setting, Kiefer and Krieger even obtain a correct approximation, showing that the UBG is in fact of only context-free power. The paper by Dowding et al. (Reference Dowding, Hockey, Gawron and Culy2001) also explores techniques for transforming CFGs into weakly equivalent grammars with less ambiguity. These investigations are important since the use of linguistically-motivated CFGs as language models often lead to confidential paths in the language model labeled with the same recognition hypothesis, so that other good hypotheses are forced out of the beam of the recognizer.
Rayner et al. (Reference Rayner, Hockey, James, Bratt, Goldwater and Gawron2000) conduct a series of experiments that employ approximated CFGs as language models in the Nuance speech recognizer. Instead of using a domain-specific UBG, Rayner et al. (Reference Rayner, Hockey, James, Bratt, Goldwater and Gawron2000) start with a general, linguistically-motivated grammar, but use a domain-specific lexicon, resulting in a domain-specific CFG. Compiling a UBG is done by enumerating all possible instantiations of features in rules. To make this approach tractable, a relatively complex mechanism is implemented to arrive at features, having only finitely-many values, similar to the approach in Moore (Reference Moore and Ponting1999). A kind of rule folding is also applied here. The compilation failed for a mid-to-large-size UBG, so they started with a small grammars and incrementally add further rules and lexicon entries. It turned out that a more complex clause structure was not responsible for the poor recognition performance of the resulting CFGs, but instead a small number of rules, basically centered around relative clause modification. The fhdings in this detailed paper might also be of interest to our method. In Rayner et al. (Reference Rayner, Gorrell, Hockey, Dowding and Boye2001 a), the explicit assumption is made that each UBG feature has a finite range of possible values. How this can be guaranteed is not explained in the paper. Further technical aspects of the above compilation method are elaborated. In the related paper (Rayner et al. 2001b), it is argued that agreement constraints from the UBG should be kept in the CFG to obtain better language models.
Bos (Reference Bos2002) comes up with a compilation method that is very related to that of Moore and Rayner et al. above. Again, features only have finitely many values and complex values are not allowed. What makes his approach unique, however, is that he shows how to transfer compositional semantics from the UBG into the CFG, using the grammar specification language GSL from the Nuance recognizer package. GSL supports slot filling for constructing semantically-relevant output, similar to W3C's VoiceXML or SRGS, and Sun's JSGF. The challenge for saving the semantics on the CFG side is elimination of left recursion in the rules and no support for features and unification. In the end, deriving a logical form for a string is achieved by running the CF parser on that string, using the approximated CFG, followed by several β-reduction steps. Recognition performance in terms of speed and word error rate is not affected by his method. Bos’ way to achieve a compositional semantics is quite close to our proposed treatment of semantic construction, using additional semantic rules (see section 5.4).
In this section, we have listed existing frameworks to grammar approximation and have tried to relate our approach to some of them (if this was possible). For instance, Carroll’ s use of symbol subsumption or the idea of applying postprocessing steps (as done in, e.g., Moore's or Dowding's framework). What makes our approach unique is that it operates on the most-specific information made available by a deep grammar, viz., the charts of a deep parser that are enriched by typed feature structures (a kind of partial evaluation). In order to obtain proper CF recognition grammars, we have adopted the concept of quick-check paths or quick-check fltering in order to equip context-free symbols with the most prominent failure points. And because we have access to the feature structures of a chart (and so to information stored in arbitrary deep-nested daughters), we can even escape the fat domain of CF rules (we haven not tried this yet).
5 Summary and extensions
As already explained in the article, the corpus-driven approximation method is unsound, that is, given a corpus C of training sentences and a set of annotation paths A (from which we determine the annotation of a context-free symbol), the approximated CF language is usually not a superset (but also not a subset) of the language accepted by the HPSG (see Figure 5). This is due to the fact that not all linguistic constructions licensed by the HPSG are covered by the training corpus, but also because not every piece of information from the TFS is encoded in the annotation of a CF symbol:
It is easy to see that more training samples C” result in a broader language:
The subset relation turns around with more annotations:
The correlation between the language accepted by the HPSG
(HPSG) and the approximated context-free language
(CFG, C, A), given a corpus C and a set of annotation paths A. The approximated language
(CFG, C′,A) monotonically grows when given a larger corpus C′ ⊇ C. The language
(CFG, C, A’) usually shrinks when given a larger set of annotation paths A’ ⊇ A (but the number of rules grows).
In both cases, more training sentences and/or more annotation paths result in larger rule set. Overall, we can say that the more information from the feature structure is put into the annotations of the context-free symbols, the better the CFG approaches the HPSG in terms of the number of readings and the less it overgenerates w.r.t. linguistic constructions contained in the training corpus.
Remember, annotated CF rules approximate HPSG (passive) chart edges, and the existence of more specirc CF symbols and rules helps to better mimic the behavior of the HPSG during CF parsing. Finding the right annotation paths, of course, depends on the application domain in which the extracted CFG is employed.
The correlation between UBGs and the family of approximated CFGs w.r.t. a given corpus and a set of annotation paths is depicted in Figure 5.
As motivated in section 3.4, when fixing a corpus C and a set of annotation paths A, the language obtained under U≡ is always a subset of the language resulting from the application of U, given the same HPSG source grammar:
However, the more general grammar has less rules due to the fact that U might delete more than one specialized rule when favoring a more general rule.
We explained in the beginning that we have taken all passive edges of the HPSG parser into account - this is a compromise. Two extremes obviously stand out: (1) using only passive edges which have led to complete HPSG readings and (2) taking all, i.e., active and passive edges into account. Approach 1 clearly generates a smaller, but more approaching language when compared to the language of the HPSG source grammar. Approach 2 leads to a much broader language due to the fact that active edges contain uninstantiated daughter positions which are usually not much restricted by the rule schemata in HPSG.
Another avenue which is worth to follow results from widening our domain of locality by moving from context-free rules to trees of depth greater than 1. This is not hard to achieve since the transmitted chart of the HPSG parser not only allows us to refer to the immediate daughters of an edge, but even to every daughter covered by this edge. Our open framework encourages experimentation towards this direction.
We will now discuss several postprocessing steps which might be applied after a CFG has been extracted.
5.7 Elimination of useless rules
Since the extracted annotated grammars are still context-free, we can remove those symbols which will never contribute to a reading. These symbols and the productions using them are called useless and there exist a fast decidable algorithm that, given a grammar, produces a smaller grammar which does not contain useless productions (Hopcroft and Ullman Reference Hopcroft and Ullman1979). The runtime efficiency of a CF parser clearly benefits from the removal of such useless productions, helping the parser to avoid dead derivation branches. Note that, in general, unsuccessful rule instantiations in the unification parser can not be computed beforehand, due to the infinite number of ‘categories’ in a unification-based grammar (the set of all feature structures produced by a UBG is usually infinite).
5.2 Automatic lexicon extension
New utterances not covered by the corpus are only recognized by the extracted CFG if they can be mapped to already parsed syntactic constructions and to already seen words. One can imagine that the relevant domain-specific syntactic constructions can be covered by a sufficiently large training corpus. Lexical gaps, however, should not be attacked by taking more samples into account. One way to enlarge the CF lexicon is by mapping lexicon entries from the HPSG to related terminal symbols in the CFG, originating from parsing the training corpus. Assume, the training corpus contains
Bill gives Mary a book
but does not mention the word cookie. A sentence such as
Bill gives Mary a cookie
will then not be recognized.
The extraction process has represented book by the unary production
where book_nl can be seen as a preterminal, speaking in terms of CFGs.
By inspecting the HPSG lexicon, we will then fhd that book is of the same lexical type as cookie, viz., book_nl. Thus we can enlarge the CF lexicon by
By exploiting this procedure, we can at least guarantee that the CFG will have the same lexical coverage than the UBG.Footnote 6
5.3 Grammar postprocessing
Lexicon extension is related to a postprocessing step which ‘taassages” the approximated CFGs, more precisely, the rules which have a preterminal symbol such as in [prep*, . . .] on their RHS. For instance, we might have
Now assume that our training corpus does not contain the preposition on and that automatic lexicon extension has added the following ‘lexicon lookup” (or lexical) rule
However, we are still missing the very likely CF rule
Constructing such new rules, however, is not that difficult. Clearly, when addressing this topic properly, the need for a larger training corpus is probably no longer that demanding.
A much simpler way to achieve more generality is, however, to omit the primary category symbol, so that the above example reduces to
Clearly, this strategy can also be applied to every nonterminal, resulting in smaller grammars, since a lot of rules will probably collapse. The results of deleting the primary category symbol of each nonterminal are presented for a small test corpus insection 6.3.
5.4 Constructing meaningful output
In case we are not only interested in a context-free boolean recognizer, but would like to see some useful output, e.g., MRS-like structures (Copestake, Lascarides and Flickinger Reference Copestake, Lascarides and Flickinger2001), we can either apply two-stage parsing here (see above), letting the UBG deterministically replay the CF parse trees, or (automatically) equip the approximated CFGs by ‘semantic rules’, similar to attribute grammars, a framework extensively used in syntax-directed translation, dating back to the early sixties (Aho, Sethi and Ullman Reference Aho, Sethi and Ullman1986).Footnote 7 The latter approach completely obviates UBG parsing and has the further advantage that overgeneration within the extracted CFG will not be prohibited by a subsequent, more restrictive UBG reparse.
Such semantic rules can not be obtained directly from the passive edges of a chart (or even from the extracted CF rules), but instead must be reconstructed from the CF rules with the help of the HPSG rule schemata, together with the total surjective mapping from CF rules to HPSG rule schemata.
Let us give an example. Assume that the training corpus contains the sentence
Tigger meows
for which we obtain, among other rules,
The unique (slightly simplifed) HPSG rule schema associated with the LHS of subjh[verb, . . .] plus the inherited HPSG principles gives us a feature structure which exactly specifes the ‘transport’ of information from the daughters to the mother (⊕ denotes list append):
This transport is expressed through coreferences (
and
) and has to be remodeled in the semantic rules attached to the CF rule. We thus enrich the above extracted CF production by the following two simplifed semantic rules (we use a kind of PATR-II notation, where 0 denotes the LHS, 1 the first RHS daughter, etc.):
The process of semantic composition must be grounded in the lexicon, thus we equip each lexicon entry of the CFG by the relevant semantic rules which can be obtained from the corresponding lexicon entries of the HPSG (let {. . .} denotes a list of elements):
But perhaps the much simpler procedure of annotating CF symbols with additional, semantically-relevant information from the feature structures might suffice. In this case, successful CF derivation trees will be reinspected in a second phase, where the according semantic information is reconstructed. This approach could also be the starting point for approximating not only recognition grammars, but even useful generation grammars.
6 CSLI's English Resource Grammar (LinGO)
We have applied our method to the large English LinGO grammar (June 2002), developed at CSLI Stanford. The grammar consists of 61 rule schemata, 8,082 non-leaf types, and a lexicon of 6,930 stems.
6.1 aged
We used the aged test suite (Oepen and Callmeier Reference Oepen and Callmeier2000), consisting of 96 syntactically highly diverse sentences to measure the quality of our approximation (average sentence length: 8.4; maximal length: 19). aged consists of 202 stems that cover a great deal of morphological and lexical variation. 719 full forms were computed from these stems. The PET parser which produced the input charts of passive edges (section 3.1) ran under no restrictions and computed 267,651 passive edges overall. One of the sentence from aged even contributed 139,028 edges. Approximation was performed under rule equivalence and rule subsumption. The length of the annotation vector was varied between 0 and 32.
Figure 6 shows the asymptotic behavior for the number of nonterminal and rules, when compared to the length of the annotation (see also Figure 3). The explosion of rules from fve to six annotations is due to the path SYNSEM | LOCAL | KEYS | KEY who potentially results in more than 4,000 possible values, representing relatively word-specific information. It is usually a good idea not to use such path values as annotations in case the rule set gets too large. Furthermore, approximated CF rules will get too specific when incorporating such information. An optional strategy to cope with such a value overload is described in Kiefer and Krieger (Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002), viz., type generalization.Footnote 8
Total number of rules for the aged test suite, obtained under both equivalence (E-rules) and subsumption (S-rules). The explosion in the number of rules from 5 to 6 is due to the path SYHSEMI|LOCAL|KEYS|KEY.
Useful and useless rules for aged, obtained under rule equivalence (without lexicon lookup rules). All measurements were conducted on a 833 MHz Linux workstation under Allegro Common Lisp 6.0.1. ppedges refers to packed passive edges.
Useful and useless rules for aged, obtained under rule subsumption (without lexicon lookup rules). The runtime is measured for the first stage of two-step parsing, i.e., for the CF stage.
The next two tables present runtime measurement and show that the useless rules outweigh when moving to larger annotation vectors. The numbers also show (at least for aged and csli, see next section) that the grammars obtained under rule equivalence are nearly of the same size as those obtained under rule subsumption, but are overall better when regarding the number of readings (readings). This will clearly gain importance in the second stage of an UBG-replay approach. Considering the UBG parser, 1,589 readings for aged were found. PET failed for 17 of the 96 sentences when using the English HPSG.
A plot of the number of rules obtained under rule equivalence against the number of samples is shown in Figure 9.
Fig. 9. Plot of the number of all rules obtained under rule equivalence against the number of samples from aged. Note that we depict the sum of useful and useless rules without start productions here. The table clearly shows that, at least for 226 symbol annotations, the training corpus is too small.
We also conducted measurements for two grammars under rule equivalence. The pure HPSG parser, fully equipped with quick-check fltering, resulted in an overall parse time of 1,361.5 seconds. Total time of two-stage parsing (CF parsing plus UBG replay using the full HPSG) for aged was
• 110 annotations: 59.4 sec = 22.9 ×speedup
• 226 annotations: 52.8 sec = 25.8 × speedup
Considering runtime, the grammar with 226 annotations was better, since HPSG replay had carried out less unifications.
6.2 csli
The csli test suite which originated from the old HP test suite developed at Hewlett Packard Labs (Oepen and Flickinger Reference Oepen and Flickinger1998), consists of 5,720 grammatical and ungrammatical samples. It is intended to cover a great deal of the syntactical constructions of English. Average sentence length is 5.0, maximal length 20. 585 full forms (= #CF terminal symbols), e.g., “little”, and 3269 lexicon lookup rules (= #preterminal symbols or lexical categories), e.g.,
can be found in every approximated grammar (i.e., average ambiguity rate per stem ≈ 5.6). The maximal number of passive chart edges in the PET parser was set to 100,000. 7,981 readings were found by PET. 3,246 sentences of 5,720 could not be analyzed by PET, given the HPSG and the edge limitation. 91 sentences of csli contain a lexical gap not covered by the lexicon of the HPSG.
For csli, we obtained the following measurements for the approximated CFGs (see Figures 10 and 11).
Number of rules (including start productions and lexicon lookup rules) and nonterminals for the csli test suite, obtained both under equivalence (E-rules, E-nonterms) and subsumption (S-rules, S-nonterms). The rule set both contains useful and useless rules.
Some of the numbers from Figure 11 were astounding on first sight. Firstly, the decrease of useful rules from 10 to 18 annotations seems to contradict to what has already been said before. However, we have always argued that the total number of all rules increases when moving to a larger annotation. This decrease is due to the fact that “older” useful rules have been outdated, i.e., have become useless through the specialization of some of their CF symbols (more annotations).
Useful and useless rules for csli, obtained under rule equivalence (without lexicon ‘lookup” rules). Less than a fourth of all rules are useful under the most specifb CFG. Note the decrease of useful rules when moving from 10 to 18 annotations, although the total number of rules increases. Note also the increase of readings from 110 to 226 annotations, even though the recognized language gets smaller (cf. number of errors). Overgeneration against the UBG (7,981 readings) w.r.t. training corpus was between 2.29 and 2.82 for the two largest grammars. Recall that the original HPSG produces 3,246 errors which are properly approximated by the most specifb CFG above (viz., 3,065). The runtime is measured for the first stage of two-step parsing, i.e., for the CF stage.
Secondly, the number of readings might increase when we equip the CF symbols with more information. Again, this does not stand in contrast to what has already been said. Clearly, a more specialized CF grammar (226 annotations) recognizes a smaller language than a more general CFG (110 annotations). This fact is supported by the number of errors in Figure 11 (more errors). ‘Older” CF rules, here, are split up into new specialized instances when adding more annotations. In a certain sense, new information might add spurious ambiguities. Thus, the CFG with 110 annotations can be seen to better approximate the UBG than the bigger CFG. This behavior should be taken into consideration in the context of two-stage UBG replay parsing.
However, the measurements for two-stage parsing (110 and 226 annotations) are of a different kind and show that the restrictedness of the CFG (= number of errors) should be taken into account when judging the practical usefulness of a grammar. The grammar with 226 annotations per symbol leads to fewer unification in the UBG replay stage. HPSG baseline for the 5,720 sentences was 2,777.3 seconds (again, quick-check fltering was switched on).
• 110 annotations: 30.7 sec = 90.5x speedup
• 226 annotations: 28.5 sec = 97.4x speedup
This speedup of nearly two magnitudes shows the enormous potential of our method. We fnish this section with a plot of the number of rules obtained under rule equivalence against the number of samples (Figure 12).
Plot of the number of all rules obtained under rule equivalence against the number of samples for csli. Note that we depict the sum of useful and useless rules without start productions here. Again, the table clearly shows that, at least for 226 symbol annotations, the training corpus is too small.
6.3 Putting it to the test
Similar to Kiefer et al. (Reference Kiefer, Krieger and Prescher2002), we chose a sample of sentences from csli as input to a test run. The corpus was divided into a training set (90% = 5148 sentences) and a test set (10% = 572 sentences) to measure the quality of the approximated CFG w.r.t. overgeneration, recognition of ungrammatical sentences, and speedup (see Figure 13).
Useful and useless rules for the 90% training corpus from csli, obtained under rule equivalence (without lexicon ‘lookup” rules). Runtime measurements (#ppedges, readings, errors, runtime[s]) are performed against the 10% test corpus (572 sentences) for full two-stage parsing (sum of both stages). Row 3 and 4 presents the results for the two grammars after deleting the main category symbols in CF rules (-CAT). Speedup is more than 100 here (compare this with the results from last subsection), since failed CF parses are, of course, not replayed by the second HPSG stage.
As already indicated by Figure 12, the training corpus is clearly too small for the approximated grammar with 226 annotations (and probably also too small for 110 annotations). Nevertheless, we conducted a test with both grammars to see how far the two-step approach is away from the HPSG baseline. The HPSG alone resulted in 382 readings and 384 errors for the 572 test sentences (= 188 well-formed sentences w.r.t. the HPSG). Two-step parsing with the approximated grammars resulted in 459 and 494 errors, resp. That is, 75/110 (= 459/494 − 384) of 188 (= 572 − 384) grammatical sentences were classifed as ungrammatical according to the missing rules hidden in the training corpus (see figure 13). The results are not as bleak as it seems, since csli is a highly diverse test suite, where the deletion of a single training sentence (and its specific syntactic structure) usually results in an approximated grammar that does not recognize this sentence. More redundant, homogeneous real-world data (say, newsgroups) will probably show a better adaption of the approximated grammars to a test sample.
The situation, however, can be improved by omitting the main category symbol in each nonterminal (of each rule). As a result, original incompatible rules suddenly collapse into a new rule (see section 5.3). This strategy in part compensates the unseen data, yielding slightly better results: 444/480 errors have now been detected (see Figure 13).
Overall, the relatively small amount of training material is responsible for recognizing only half of the grammatical sentences (recall the curves for the two most restrictive grammars in figure 11). In case we do not have enough training material, a more ‘liberal grammar” might be a good compromise here for two-stage parsing, since it produces less errors (see the first line in Figure 13 for the CFG with 32 annotations). However, such a grammar clearly shifts a larger workload to the HPSG side.
7 Conclusion and outlook
In this article, we have described a corpus-driven method for extracting domain-specific context-free grammars. We have presented a variation of this method that will usually yield smaller grammars while having the drawback of being more general. The measurements have shown that we can not take much advantage of the second method, but one can imagine “weird” UBGs where this method produces CFGs that are exponentially smaller than grammars produced by the first method (see also Kiefer and Krieger Reference Kiefer, Krieger, Oepen, Flickinger, Tsuji and Uszkoreit2002). We have also indicated that the approximated CFGs can be turned into PCFGs for disambiguating UBGs in a two-step parsing approach, similar to the treatment in Kiefer et al. (Reference Kiefer, Krieger and Prescher2002). Furthermore, the approximated CFGs are of interest to domain-specific NLP applications which are eagerly waiting for cheap and easily-to-produce recognition grammars, e.g., information extraction or language modeling. Finally, we suggested that, starting from the results reported in Rayner et al. (Reference Rayner, Gorrell, Hockey, Dowding and Boye2001b), the approximated CFGs are a good starting point for obtaining better language models.
The approach neither generates a true superset nor a true subset of the language accepted by the UBG, but clearly better fits the UBG when given a larger training sample and more annotation values. As we have already indicated, this seeming misbehavior is a desired property, when looking for robust domain-specirc grammars. The measurements presented here are very encouraging, but needs to be scrutinized in a domain-specirc NLP system.
In case we are not interested in a domain-specific context-free subgrammar of the UBG, even the World Wide Web can be seen as a huge training corpus, due to the following argument. Given a large-scale UBG and a UBG parser (e.g., PET), it is clear that even ungrammatical utterances or utterances not covered by the UBG are worth to be partially parsed, since the UBG parser always comes up with a chart from which we can compute further CF rules which approximate, at least, legal phrases, although the UBG parser has failed overall. This idea clearly rises or falls with the quality of the UBG. Unknown words not covered by the UBG (mostly named entities) are also an important topic that needs to be addressed. A viable solution here is to have some kind of named entity grammars, processed in a weaker formalism. Such a shallow formalism will then be invoked in a preprocessing phase when unknown words are detected, producing lexicon entries for the UBG, which ultimately will show up in the CFG later.Footnote 9
As indicated in section 5.4, it is worth to extract not only recognition rules, but also to have semantic rules as in attribute grammars, so that our CFGs will come along with some meaningful output. This idea would obviate the need for a second unification-based grammar that replays the CF derivations for the mere purpose of semantic construction. However, a third line can be taken here by employing ideas from Diagne et al. (Reference Diagne, Kasper and Krieger1995), Kasper and Krieger (Reference Kasper and Krieger1996) and Kasper et al. (Reference Kasper, Krieger, Spilker and Weber1996). Instead of using the full feature structures of a UBG G during replay, we only employ the related grammar G’ derived from G: rules and lexicon entries in G’ are exactly the feature structures from G that have been evaporated under an appropriate restrictor R (Shieber Reference Shieber1985): G′ = G∖R. Since we are interested in successful UBG derivations and since we like to keep the CF language generalizations in the second replay stage, we delete those constraints on the UBG side which potentially lead to a unification failure (mostly the syntactic constraints). In HPSG-I (Pollard and Sag Reference Pollard and Sag1987), specifying the restrictor is easy -mostly the information under SYN must be deleted. And in case we are interested in a more shallow semantics, some semantic information from SEM has to be deleted too.
Within the next months, we hope to expand this implemented framework in three directions.
Firstly, by using the latest version of the HPSG and more training material, we will try to extend the coverage of the approximated grammars. We will also experiment with more annotations attached to the CF symbols in order to make the CFGs even more specific. The experiments with the csli test suite have shown that even a duplication of annotations (from 110 to 226) does not increase the number of useful rules that much (40,742 vs. 58,394 rules).
Secondly, we will cary out experiments to measure the disambiguation quality of the approximated grammars in a two-step parsing framework, similar to the treatment in Kiefer et al. (Reference Kiefer, Krieger and Prescher2002). Since our CFGs are more specific than those produced by the purely grammar-driven approximation in Kiefer et al. (Reference Kiefer, Krieger and Prescher2002), we hope to obtain better disambiguation results.
Thirdly, by compiling the resulting CFGs into language models (using, for instance, Nuance and its GSL formalism), it would be interesting to see how much the CFGs can contribute to the quality of the search in the speech recognizer. We hope to answer this question in a students’ software project in a few months.
Acknowledgements
First of all, my thanks go to Bernd Kiefer for providing me with the modifed parsers and for helping me adapting the grammars. His help during the measurements is gratefully acknowledged. I have also benefited from many discussions with him. I am also grateful to the three JNLE reviewers for their detailed and well-meaning comments. Thank you. Finally, I would like to thank John Carroll for encouraging me to submit the manuscript to Natural Language Engineering. This work was supported in a first phase by the Verbmobil project (grant no. 01 IV 701 V0), resulting in a LISP implementation of the approach in summer 1998, realized on top of the Verbmobil deep core engine (Kiefer et al. Reference Kiefer, Krieger, Nederhof and Wahlster2000). This first implementation of the extraction method was used by Nederhof (Reference Nederhof2000) to produce CFGs of different size and specifcity during his experiments with regular approximation of context-free languages. An extended first JAVA reimplementation was fnished in autumn 2002 and was further extended in spring 2004. Parts of the implementation, the writing of this article, and the measurements were funded by the German BMBF under grant no. 01 IW C02 (QUETAL).