File Information
File: 05-lr/acl_arc_1_sum/cleansed_text/xml_by_section/metho/92/p92-1011_metho.xml
Size: 19,121 bytes
Last Modified: 2025-10-06 14:13:12
<?xml version="1.0" standalone="yes"?> <Paper uid="P92-1011"> <Title>COMPARING TWO GRAMMAR-BASED GENERATION A CASE STUDY</Title> <Section position="4" start_page="0" end_page="81" type="metho"> <SectionTitle> 2. MAIN CHARACTERISTICS OF SHDGA'S AND EAA'S TRAVERSALS </SectionTitle> <Paragraph position="0"> SHDGA traverses the derivation tree in the semantic-head-first fashion. Starting from the goal predicate node (called the root), containing a structured representation (semantics) from which to generate, it selects a production whose leg-hand side semantics unifies with the semantics of the root. If the selected production passes the semantics unchanged from the left to some nonterminal on the right (the so-called chain rule), this later nonterminal becomes the new root and the algorithm is applied recursively. On the other hand, if no right-hand side literal has the same semantics as the root (the so called non-chain rule), the production is expanded, and the algorithm is reeursively applied to every literal on its right-hand side. When the evaluation of a non-chain rule is completed, SHDGA connects its left-hand side literal (called the pivot) to the initial root using (in a backward manner) a series of appropriate chain rules. At this time, all remaining literals in the chain rules are expanded in a fixed order (left-to-right).</Paragraph> </Section> <Section position="5" start_page="81" end_page="81" type="metho"> <SectionTitle> 2 Deadlock-prone rules are rules in which the order of the ex- </SectionTitle> <Paragraph position="0"> pansion of right-hand side literals cannot be determined locally (i.e. using only information available in this rule).</Paragraph> <Paragraph position="1"> Since SHDGA traverses the derivation tree ha the fashion described above, this traversal is neither top-down ('I'D), nor bottom-up (BU), nor left-to-right (LR) globally, with respect to the entire tree. However, it is LR locally, when the siblings of the semantic head literal are selected for expansion on the right-hand side of a chain rule, or when a non-chain rule is evaluated.</Paragraph> <Paragraph position="2"> In fact the overall traversal strategy combines both the TD mode (non-chain rule application) and the BU mode (backward application of chain rules).</Paragraph> <Paragraph position="3"> EAA takes a unification grammar (usually Prologcoded) and normalizes it by rewriting certain left recursive rules and altering the order of right-hand side nonterminals in other rules. It reorders literals ha the original grammar (both locally within each rule, and globally between different rules) ha such a way that the optimal traversal order is achieved for a given evaluation strategy (eg. top-down left-to-righ0. This restructuring is done at compile time, so in effect a new executable grammar is produced. The resulting parser or generator is TD but not LR with respect to the original grammar, however, the new grammar is evaluated TD and LR (i.e., using a standard Prolog interpreter).</Paragraph> <Paragraph position="4"> As a part of the node reordering process EAA calculates the minimal sets of essential arguments (msea's) for all literals ha the grammar, which in turn will allow to project an optimal evaluation order. The optimal evaluation order is achieved by expanding only those literals which are ready at any given moment, i.e., those that have at least one of their mseas instantiated. The following example illustrates the traversal strategies of both algorithms. The grammar is taken from \[SNMP90\], and normalized to remove deadlock-prone rules in order to simplify the exposition? (0) sentence/deel(S)--> s(f'mite)/S.</Paragraph> <Paragraph position="5"> (1) sentence/imp(S) -- > vp(nonfmite,\[np(_)/you\]) IS.</Paragraph> <Paragraph position="6"> ,,.....</Paragraph> <Paragraph position="7"> (2) s(Form)/S - > Subj, vp(Form,\[Subj/S.</Paragraph> <Paragraph position="8"> ...degdegdeg.</Paragraph> <Paragraph position="9"> (3) vp(Form,Subcat)/S -- > v(Form,Z)/S, vpl(Form,Z)/Subcat.</Paragraph> <Paragraph position="10"> (4) vpl(Form,\[Compl\[ Z\])/Ar --> vpl(Form, Z)/Ar, Compl.</Paragraph> <Paragraph position="11"> (5) vpl(Form,Ar)/Ar.</Paragraph> <Paragraph position="12"> (6) vp(Form,\[Subj\])/S -- > v(Form,\[Subj\])/VP, anx(Form, \[Subj\],VP)/S.</Paragraph> <Paragraph position="13"> (7) anx(Form,\[Subjl,S)/S.</Paragraph> <Paragraph position="14"> (8) aux(Form,\[Subjl,A)/Z--> adv(A)/B, aux(Form\[Subj\],B)/Z.</Paragraph> <Paragraph position="15"> .......</Paragraph> <Paragraph position="16"> (9) v(finite,\[np(_)/O,np(3-sing)lS\])llove(S,O) -- > \[loves\].</Paragraph> <Paragraph position="17"> (10) v(f'mite, \[np(_)/O,p/up,np(3 -sing)/S\])/ call_up(S,O) -- > \[calls\].</Paragraph> <Paragraph position="18"> (11) v(fmite,\[np(3-sing)/S\])/leave(S) -- > \[leaves\]. ...... deg (12) np(3-sing)/john -- > \[john\].</Paragraph> <Paragraph position="19"> (13) np(3-pl)/friends -- > \[friends\].</Paragraph> <Paragraph position="20"> (14) adv(VP)/often(VP)--> \[often\].</Paragraph> <Paragraph position="21"> The analysis tree for both algorithms is presented on the next page. (Figure 1.). The input semantics is given as decl(call_up~ohnfriends)). The output string becomes john calls up friends. The difference lists for each step are also provided. They are separated from the rest of the predicate by the symbol I- The different orders in which the two algorithms expand the branches of the derivation tree and generate the terminal nodes are marked, ha italics for SHDGA, and in roman case for EAA. The rules that were applied at each level are also given.</Paragraph> <Paragraph position="22"> If EAA is rerun for alternative solutions, it will produce the same output string, but the order in which nodes vpl (finite,\[p/up,np(3-sing)/john\])/\[Subj\]/Sl_S2, and np(..)/~ends/S2__l\] (level 4), and also, vp1(finite,\[np(3sing)/john\])/\[Subj\]/S1_S12, and p/up/S12_S2, at the level below, are visited, will be reversed. This happens because both literals in both pairs are ready for the expansion at the moment when the selection is to be made. Note that the traversal made by SHDGA and the first traversal taken by EAA actually generate the terminal nodes ha the same order. This property is formally defined below.</Paragraph> <Paragraph position="23"> Definition. Two traversals T' and T&quot; of a tree T are said to be the same-to-a-subtree (stas), if the followhag claim holds: Let N be any node of the tree T, and S~ ..... S all subtrees rooted at N. If the order in which the subtrees will be taken on for the traversal by T' is S? ..... S. n and by T&quot; S. t ..... S.&quot;, then SJ =SJ ..... S.&quot;=S.&quot;. s s .1 J l .I t j (S~ is one of the subtrees rooted at N, for any k, and 1) Stas however does not imply that the order in which the nodes are visited will necessarily be the same.</Paragraph> </Section> <Section position="6" start_page="81" end_page="83" type="metho"> <SectionTitle> 3. GENERALITY-WISE SUPERIORITY OF EAA OVER SHDGA </SectionTitle> <Paragraph position="0"> The traversals by SHDGA and EAA as marked on the graph are stas. This means that the order in which the terminals were produced (the leaves were visited) is the same (in this case: calls up friends john). As noted previously, EAA can make other traversals to produce the same output string, and the order in which the terminals are generated will be different in each case.</Paragraph> <Paragraph position="1"> (This should not be confused with the order of the terminals in the output string, which is always the same).</Paragraph> <Paragraph position="2"> The orders in which terminals are generated during alternative EAA traversals are: up calls friends john, friends calls up john, friends up calls john. In general, EAA can be forced to make a traversal corresponding to any permutation of ready literals in the right-hand side of a rule.</Paragraph> <Paragraph position="3"> We should notice that in the above example SHDGA happened to make all the right moves, i.e., it always expanded a literal whose msea happened to be instantiated. As we will see in the following sections, this will not always be the case for SHDGA and will become a source of serious efficiency problems. On the other hand, whenever SHDGA indeed follows an optimal traversal, EAA will have a traversal that is same-to-a-subtree with it.</Paragraph> <Paragraph position="4"> The previous discussion can be summarized by the next theorem.</Paragraph> <Paragraph position="5"> Theorem: If the SHDGA, at each particular step during its implicit traversal of the analysis tree, visits only the vertices representing literals that have at least one of their sets of essential arguments instantiated at the moment of the visit, then the traversal taken by the SHDGA is the same-to-a-subtree (stas) as one of the traversals taken by EAA.</Paragraph> <Paragraph position="6"> The claim of the theorem is an immediate consequence of two facts. The first is that the EAA always selects for the expansion one of the literals with a msea currently instantiated. The other is the definition of traversals being same-to-a-subtree (always choosing the same subtree for the next traversal).</Paragraph> <Paragraph position="7"> The following simple extract from a grammar, defining a wh-question, illustrates the forementioned (see ........ .deg (1) whques/WhSem--> whsubj(Num)/WhSubj, whpred(Num,Tense, \[WhSubj,WhObj\]) /WhSem, whobj/WhObj.</Paragraph> <Paragraph position="8"> o.o ...... .</Paragraph> <Paragraph position="9"> ....... ,.deg (2) whsubj(_.)/who -- > \[who\].</Paragraph> <Paragraph position="10"> (3) whsubj(__)/what --> \[what\].</Paragraph> <Paragraph position="11"> degdeg ...... ,deg (4) whpred(sing,perf, \[Subj, Obj\])/wrote(Subj, Obj) -> \[wrote\].</Paragraph> <Paragraph position="12"> ...deg.,,,deg, (5) whobj/this--> \[this\].</Paragraph> <Paragraph position="13"> degdegoo,ooodegdeg The input semantics for this example is wrote(who,this), and the output string who wrote this. The numbering for the edges taken by the SHDGA is given in italics, and for the EAA in roman case. Both algorithm~ expand the middle subtree first, then the left, and finally the right one.</Paragraph> <Paragraph position="14"> Each of the three subtrees has only one path, therefore the choices of their subtrees are unique, and therefore both algorithms agree on that, too. However, the way they actually traverse these subtrees is different. For example, the middle subtree is traversed bottom-up by SHDGA and top-down by EAA. whpred is expanded first by SI-IDGA (because it shares the semantics with the root, and there is an applicable non-chain rule), and also by EAA (because it is the only literal on the right-hand side of the rule (1) that has one of its msea's instantiated (its semantics)). After the middle subtree is completely expanded, both sibling literals for the whpred have their semantics instantiated and thus they are both ready for expansion. We must note that SHDGA will always select the left-most literal (in this case, whsubj), whether it is ready or not. EAA will select the same in the first pass, but it will expand whobj first, and then whsubj, if we force a second pass. In the first pass, the terminals are generated in the order wrote who this, while in the second pass the order is wrote this who. The first traversal for EAA, and the only one for SHDGA are same-to-asubtree. null</Paragraph> </Section> <Section position="7" start_page="83" end_page="85" type="metho"> <SectionTitle> 4. EFFICIENCY-WISE SUPERIORITY OF EAA OVER SHDGA </SectionTitle> <Paragraph position="0"> The following example is a simplified fragment of a parser-oriented grammar for yes or no questions. Using this fragment we will illustrate some deficiencies of (3) auxverb(sing, one,pres__perf)/laave(pres__perf, sing) --> \[have\].</Paragraph> <Paragraph position="1"> (4) aux_verb(sing,one,pres_cont)/be(pres_cont, sing-l)--> \[am\].</Paragraph> <Paragraph position="2"> (5) auxverb(sing,one,pres)/do(pres,sing- 1) -- > \[do\]. (6) aux_verb(sing,two,pres)/do(pres,sing-2)--> \[do\]. (7) aux_verb(sing,three,pres)/do(pres,sing-3) -- > \[does\].</Paragraph> <Paragraph position="3"> (8) aux_verb(pl,one,pres)/do(pres,pl-1) -- > \[do\]. (9) subj(Num,Pers)/Subj -- > np(Num, Pers,su)/Subj. (10) obj(Num,Pers)/Obj -- > np(Num,Pers,ob)/Obj. (11) np(Num,Pers,Case)/NP --> noun(Num,Pers, Case)/NP.</Paragraph> <Paragraph position="4"> (12) np(Num,Pers,Case)/NP --> pnoun(Num,Pers, Case)/NP.</Paragraph> <Paragraph position="5"> (13) pnoun(sing,two,su)/you -- > \[you\].</Paragraph> <Paragraph position="6"> (14) pnoun(sing,three,ob)/him -- > \[him\]. (15) main_verb(pres,\[Subj,Obj\])/see(Subj,Obj) --> \[see\].</Paragraph> <Paragraph position="7"> (15a) main_verb(pres__perf, \[Subj, Obj \])/seen(Subj, Obj ) --> \[seen\].</Paragraph> <Paragraph position="8"> (15b) mainverb(perf, \[Subj,Obj\])/saw(Subj, Obj) --> \[saw\].</Paragraph> <Paragraph position="9"> (16) adj(\[Verb\])/often(Verb)--> \[often\]. The analysis tree (given on Figure 3.) for the input semantics ques ( askif (often (see (you,him) ) ) ) (the output string being do you see him often) is presented below.</Paragraph> <Paragraph position="10"> Both algorithms start with the rule (1). SHDGA selects (1) because it has the left-hand side nonterminal with the same semantics as the root, and it is a non-chain rule. EAA selects (1) because its left-hand side unifies with the initial query (-?- sentence (OutString__G) / ques(askif(often(see(you,him)))) ).</Paragraph> <Paragraph position="11"> Next, rule (2) is selected by both algorithms. Again, by SHDGA, because it has the left-hand side nonterminal with the same semantics as the current root (yesnoq/askif...), and it is a non-chain rule; and by EAA, because the yesnoq/askif.., is the only nonterminal on the right-hand side of the previously chosen rule and it has an instantiated msea (its semantics). The crucial difference takes place when the right-hand side of rule (2) is processed. EAA deterministically selects adj for expansion, because it is the only rhs literal with an instantiated msea's. As a result of expanding adj, the main verb semantics becomes instantiated, and therefore main__verb is the next literal selected for expansion. After processing of main_verb is completed, Subject, Object, and Tense variables are instantiated, so that both subj and obj become ready. Also, the tense argument for aux_verb is instantiated (Form in rule (2)). After subj,</Paragraph> <Paragraph position="13"> and obj are expanded (in any order), Num, and Pers for aux_verb are bound, and finally aux_verb is ready, too.</Paragraph> <Paragraph position="14"> In contrast, the SHDGA will proceed by selecting the leftmost literal (auxverb(Num,Pers,Form)/Aux) of the rule (2). At this moment, none of its arguments is instantiated and any attempt to unify with an auxiliary verb in a lexicon will succeed. Suppose then that have is returned and unified with aux_verb with pres._perf as Tense and sing_l as Number. This restricts further choices of subj and main_verb. However, obj will still be completely randomly chosen, and then adj will reject all previous choices. The decision for rejecting them will come when the literal adj is expanded, because its semantics is often(see(you,him)) as inherited from yesnoq, but it does not match the previous choices for aux_verb, subj, main_verb, and obj. Thus we are forced to backtrack repeatedly, and it may be a while before the correct choices are made.</Paragraph> <Paragraph position="15"> In fact the same problem will occur whenever SHDGA selects a rule for expansion such that its leftmost right-hand side literal (first to be processed) is not ready. Since SHDGA does not check for readiness before expanding a predicate, other examples similar to the one discussed above can be found easily. We may also point out that the fragment used in the previous example is extracted from an actual computer grammar for English (Sager's String Grammar), and therefore, it is not an artificial problem.</Paragraph> <Paragraph position="16"> The only way to avoid such problems with SHDGA would be to rewrite the underlying grammar, so that the choice of the most instantiated literal on the righthand side of a rule is forced. This could be done by changing rule (2) in the example above into several rules which use meta nonterminals Aux, Subj, Main_Verb, and Obj in place of literals attx verb, subj, mainverb, and obj respectively, as shown below: .....deg....</Paragraph> <Paragraph position="17"> yesnoq/askif(S)--> askif/S.</Paragraph> <Paragraph position="18"> askif/S -- > Aux, Subj, Main Verb, Obj, adj (\[Verb\],\[Aux,S-ubj,Main_Verb,Obj\])IS.</Paragraph> <Paragraph position="19"> ..........</Paragraph> <Paragraph position="20"> Since Aux, Subj, Main_Verb, and Obj are uninstantiated variables, we are forced to go directly to adj first. After adj is expanded the nonterminals to the left of it will become properly instantiated for expansion, so in effect their expansion has been delayed.</Paragraph> <Paragraph position="21"> However, this solution seems to put additional burden on the grammar writer, who need not be aware of the evaluation strategy to be used for its grammar.</Paragraph> <Paragraph position="22"> Both algorithms handle left recursion satisfactorily. SHDGA processes recursive chain rules rules in a constrained bottom-up fashion, and this also includes deadlock prone rules. EAA gets rid of left recursive rules during the grammar normalization process that takes place at compile-time, thus avoiding the run-time overhead.</Paragraph> </Section> <Section position="8" start_page="85" end_page="85" type="metho"> <SectionTitle> 5. MULTI-DIRECTIONALITY </SectionTitle> <Paragraph position="0"> Another property of EAA regarded as superior over the SHDGA is its mult-direcfionality. EAA can be used for parsing as well as for generation. The algorithm will simply recognize that the top-level msea is now the string, and will adjust to the new situation. Moreover, EAA can be run in any direction paved by the predicates' mseas as they become instantiated at the time a rule is taken up for expansion.</Paragraph> <Paragraph position="1"> In contrast, SHDGA can only be guaranteed to work in one direction, given any particular grammar, although the same architecture can apparently be used for both generation, \[SNMP90\], and parsing, \[K90\], \[N89\].</Paragraph> <Paragraph position="2"> The point is that some grammars (as shown in the example above) need to be rewritten for parsing or generation, or else they must be constructed in such a way so as to avoid indeterminacy. While it is possible to rewrite grammars in a form appropriate for head-first computation, there are real grammars which will not evaluate efficiently with SHDGA, even though EAA can handle such grammars with no problems.</Paragraph> </Section> class="xml-element"></Paper>