• Aucun résultat trouvé

Categorial Grammars

Dans le document Prolog and Natural-Language Analysis D (Page 121-125)

4.3 Problem Section: Grammar Extensions

4.3.4 Categorial Grammars

A categorial grammar (CG) specifies a language by describing the combinatorial pos-sibilities of its lexical items directly, without the mediation of phrase-structure rules (like CFG or DCG rules). Consequently, two grammars in the same categorial gram-mar system differ only in the lexicon.

The ways in which a phrase can combine with other phrases are encoded in a category associated with the phrase. The set of categories is defined inductively as follows:

• A primitive category is a category. For the purposes of this problem, the primi-tive categories are S and NP.

If A and B are categories then A/B and A\B are categories. These are called compound or functor categories.

• Nothing else is a category.

Combination of phrases is sanctioned by their categories according to two rules:

Forward application (FA): A phrase pfof category A/B can be combined with a phrase paof category B to form a phrase pfpaof category A.

Backward application (BA): A phrase pf of category A\B can be combined with a phrase paof category B to form a phrase papfof category A.

Notice that the direction of the slash (“/” or “\”) determines which side of the functor phrase its argument will be found on (right or left, respectively).

As an example of a categorial grammar, we might associate lexical items with categories as follows:

type of word examples category

proper nouns Terry NP

Bertrand Principia

intransitive verbs halts S\NP transitive verbs wrote (S\NP)/NP

met

Then combining “wrote” and “Principia” by FA, we conclude that “wrote Principia”

is of category S\NP. Combining this with “Bertrand”, we have that “Bertrand wrote Principia” is an S . As usual, we can summarize the derivation in a parse tree as in Figure 4.4

Problem 4.10 Write a Prolog program (including DCG rules) to implement a catego-rial grammar system. Lexical entries can be encoded as unit clauses of the form

lex( bertrand, NP ).

lex( halts, S\NP ).

lex( wrote, (S\NP)/NP ).

...

wrote Principia Bertrand (S\NP)/NP NP

NP S\NP S

Figure 4.4: Parse tree for categorial grammar derivation

Given a lexicon encoded as above, the program should be able to parse sentences containing those lexical items.

Categorial grammars have been widely used in linguistic research concerning se-mantics of natural language. The close relation between CG and semantic interpreta-tion follows from the observainterpreta-tion that forward or backward syntactic applicainterpreta-tion of a functor category to its argument corresponds to the semantic applications of the cor-responding logical forms. Thus, the application rules can be used to control semantic application as well as syntactic combinatorics. We merely make sure that lexical items are associated with semantic functions which correspond to the syntactic functions im-plicit in their categories. For instance, a phrase of category S/NP must semantically be a function from NP-type items to S-type items. In terms of logical forms, it must be associated with a lambda expression of the formλx.φforφa formula. (This re-lationship can be made more rigorous by defining a notion of type and using a typed lambda-calculus for the logical forms, as Montague in fact did.)

The logical forms of Section 4.1.2 are appropriate for the category assignments above. Given these logical forms, we can determine the logical form for the entire sentence by performing the applications according to the syntactic structure of the sentence. For instance, since “wrote” is associated with a functor category applying (by FA) to “Principia”, we apply its logical formλx.λy.wrote(y,x) to that of its argu-ment principia yieldingλy.wrote(y,principia). Similarly, by BA, we will associate the whole sentence with the logical form wrote(bertrand,principia). The beauty of this system is that the semantic constraints are universal, as opposed to the types of grammars seen previously in which semantic constraints are stated on a rule-by-rule basis. Merely augmenting the lexicon with primitive LFs determines LFs for all the possible sentences admitted by the grammar.

Problem 4.11 Augment your solution to the previous problem so that logical forms are built during parsing.

Problem 4.12 Using the solution to Problem 4.11 write a categorial grammar which handles quantified NPs as in Section 4.1.5 and builds logical forms. You should need to change only the lexicon. Take IV, N, and S to be the primitive categories.

As a side note to the discussion of categorial grammar, note that since the matching of the argument category to the requirement of the functor category proceeds by unifi-cation, we can use full terms instead of atoms as the primitive categories and thereby

4.4. Bibliographic Notes

This digital edition of Prolog and Natural-Language Analysis is distributed at no charge for noncommercial use by Microtome Publishing.

113

pass information among the categories in ways reminiscent of DCGs. In fact, this extension to categorial grammar which we get “for free” is the correlate of the DCG extension to CFGs. Systems that use unification for matching in categorial grammars have come to be known as categorial unification grammars and are the subject of ac-tive research.

4.4 Bibliographic Notes

Our discussion of semantic interpretation (Section 4.1) is loosely based on some of the ideas of Montague grammar, although our goals are radically more modest than Mon-tague’s. Basically, we take from Montague the idea of using some form of the lambda calculus to represent the meanings of phrases and function application as the means of combining the meanings of subphrases into the meaning of a phrase. The simpli-fications in our presentation are made clear by observing that the fully reduced form for the meaning of a sentence is given by a first-order sentence. In contrast, sentence meanings in Montague have to be represented by sentences in the much richer system of intensional logic (IL), because the English fragment under consideration includes semantic phenomena such as intensional contexts (as in “John seeks a unicorn”).

Montague introduced his approach to the relation between syntax and semantics of natural language in the articles “English as a Formal Language,” “Universal Gram-mar,” and “The Proper Treatment of Quantification in Ordinary English” which have been reprinted in the volume of his selected works edited by Thomason (1974). The textbook by Dowty, Wall, and Peters (1981) gives a full account of Montague’s theory and of all the required background material, which is omitted in Montague’s extremely concise papers. For further details on the lambda calculus (Section 4.1.1), and in par-ticular its logical and computational properties, we refer the reader to the book by Hindley and Seldin (1986) for the untyped lambda calculus, and the book by Andrews (1986) for the typed lambda calculus (Church’s simple theory of types).

Our Prolog encoding of semantic interpretation rules, and in particular the encod-ing ofβ-reduction as unification, was implicit in the early work on logic grammars (Colmerauer, 1982; Dahl, 1981; Pereira and Warren, 1980). Our presentation tries to make clear the connection between the logic grammar techniques and the techniques of compositional semantics. Some of our semantic rules are clearly too simplistic, and were shown mainly to illustrate the power of the logical variable for incrementally building complex descriptions. More sophisticated examples can be found in the Pro-log natural-language analysis literature (McCord, 1982; F. C. N. Pereira, 1982; Dahl and McCord, 1983). Compositional semantics based on Montague grammar has also been used in natural-language processing systems not based on logic programming (Rosenschein and Shieber, 1982; Warren and Friedman, 1982; Schubert and Pelletier, 1982). Moore (1981) surveys some of the main difficulties involved in constructing logical representations for the meanings of a wider class of natural-language construc-tions. Last but not least, it should be noted that the above work on computing logical forms for natural-language derives many of its analyses and techniques from Woods’s early and influential research (1977).

As we noted, the encoding ofβ-reduction in unification has to be used very care-fully because of the lack of a full reduction mechanism forλ-terms within Prolog. This question has been discussed in detail by D. S. Warren (1983), and a general solution

in the framework of a Prolog extension based on Church’s simple theory of types was given by Miller and Nadathur (1986).

Partial execution has long been in the folklore of logic programming. The notion is implicit in Kowalski’s connection-graph resolution proof procedure (1975; Eisinger, 1986). A related notion in functional programming is Burstall and Darlington’s unfold-ing rule for program transformation (1977). Their techniques were extended to logic programs by Clark and Sickel (1977) and Tamaki and Sato (1984), among others. Fur-ther techniques involving deductive derivations of programs are discussed by Clark and T¨arnlund (1977) and Hogger (1981).

The discussion of quantifier scope in Section 4.1.6 presents a simplified version of some of the concepts developed independently by Woods in a computational frame-work (1977) and by Cooper in a compositional semantics setting (1983). In particular, the explicit notion of quantifier storage is due to Cooper. Hobbs and Shieber (1987) give a precise account of an algorithm for generating scope alternatives and prove some important properties relative to its soundness and completeness. Reliable criteria for choosing among scoping alternatives are notoriously hard to come by. Vanlehn (1978) gives a comprehensive account of the difficulties. Various partial engineering solutions for the problem have nevertheless been proposed (Woods, 1977; F. C. N. Pereira, 1982;

Grosz et al., 1987).

Our treatment of the English auxiliary system in Section 4.2.1 is based on that by Gazdar et al. (1982).

The treatment of long-distance dependencies and, in particular, filler-gap depen-dencies given in Section 4.2.3 is rather idealized, its goal being just to outline a few basic techniques. For a linguistically sophisticated treatment of the problem covering a much broader subset of English, see for example the book by Gazdar et al. (1985). The analysis of subject relatives as being composed from VPs and not Ss follows Gazdar (1981). Island constraints were originally proposed by Ross (1974).

As far as we know, the idea of gap threading appeared first, in form somewhat different from the one used in Section 4.2.7, as part of the extraposition grammar formalism (Pereira, 1981). It has been reinvented numerous times.

Categorial grammars as formal systems originated with the work of the Polish lo-gicians Le´sniewski and Adjukiewicz in the 1930s, but it was Bar-Hillel (1964) who considered their application to natural-language syntax. With Gaifman and Shamir, Bar-Hillel proved that the basic categorial grammars have the same weak generative capacity as context-free grammars. Lambek (1961) provided important early research in the area. Since this work, many different categorial accounts of the syntax and se-mantics of natural languages have been developed, including those by Lewis (1972) and by Cresswell (1973) from a philosophical perspective and that of Ades and Steed-man (1982) from a linguistic one. Van Benthem (1986) provides a recent survey of logical and semantic issues in categorial grammar. For discussion of categorial unifi-cation grammars, see the papers by Karttunen (1986) and Uszkoreit (1986) and works cited therein.

This digital edition of Prolog and Natural-Language Analysis is distributed at no charge for noncommercial use by Microtome Publishing.

Chapter 5

Full Prolog and a

Simple Dialogue Program

This digital edition of Pereira and Shieber’s Prolog and Natural-Language Analysis is distributed at no charge by Microtome Pub-lishing under a license described in the front matter and at the web site. A hardbound edition (ISBN 0-9719997-0-4), printed on acid-free paper with library binding and including all appendices and two indices (and without these inline interruptions), is available from www.mtome.comand other booksellers.

The subset of Prolog used up to this point has been pure in the sense that a Prolog system can be viewed as a sound (though incomplete) inference engine for a particular logic. However, the Prolog language includes several extralogical facilities which have been found to be of considerable utility in writing large programs. Some of these facil-ities are referred to as “metalogical” because their semantic domain is the domain of logical expressions and proofs. This section introduces some of the most important ex-tralogical mechanisms in Prolog by means of an example of a simple natural-language dialogue program,talk.

5.1 Metalogical Facilities

Dans le document Prolog and Natural-Language Analysis D (Page 121-125)