• Tidak ada hasil yang ditemukan

PARSING AND CONDITION FUNCTIONS

Dalam dokumen lment of the Requirements for the Degree of (Halaman 111-114)

Chomsky's fourth demand was for 11a method of determining the structural description of a sentence, given a grammar.11 The REL System includes a genera I purpose parser, emp I oy i ng an a I gar i thm s i mi I ar to Martin Kay's 11powerful parser11 (1987]. The unique advantage of this parsing a I gar i thm is that. it parses genera I rewrite ru I e grammars and finds ever';! va Ii d parse of an input sentence once and ~ once. The current implementation of the parser ls due to Frederick 8. Thompson, and is described in de ta i I in [Thompson 1974b] •

The parser operates on a structure cal led the parsing~-

It

is a directed, acyclic graph which is initially a single strand of arcs, each label led with one phrase {character) of the input sentence to be analyzed. As each rule is applied, the rule's left hand side is added as an arc { s tr i ng o f arcs i n the genera I r ew r i t e r u I e case) w h i ch de f i n es an alternate path to the existi~g right hand side. Each newly added arc is label led by a phrase marker which includes a reference to each non- terminal (constituent} in the rule's rhs. The parser operates from bottom to top and right to left. When no more rules of grammar apply, the parse is completed, and every arc label led by <sentence> which spans from a <s tr i ng_beg in> to a <str i ng_end> arc is a va Ii d parse of the input sentence. If no such arc exists, the str.i ng is not a sentence, and the input is syntacticalll;J meaningless; if more than one such arc exists, the sentence is S\;jntactical ly ambiguous. A sentence can also be

semantical l!d meaningless, if in the

-

evaluation of each of its possible meanings some semantic function executes the standard function fa i I.

Semantic ambiguity is also possible, and the whole subject of ambiguity is taken up below.

To give the language writer an additional degree of control

over

the operation of the parser, each LWL rule may specify a condition function, to be evaluated when the parser is about to apply the associated grammar rule. The checking and setting of features and any transformations specified in the rule are performed before the condition function is invoked. The constituents of the condition function are: the I ist of phrases constructed by the parser which would have become the labels of arcs inserted into the parsing graph, and the recursion stack of the parser,. from which its total environment is accessible. The value of a condition function is~ list of phrases, which are added to the parsing graph in the normal way, or !:i.!_, in which case the current - rule fai Is and nothing is added to the parsing graph.

The name of the cond i ti on function is wr i t ten be tween the two colons of the "production arrow"

(::=).

For example, if we wished to evaluate <subject>s to <q_subject>s during the parsing

_

process, w~ would write the primitive_subject rula as

primitive_subject rule <q_subject> :evaluate:= <subject>

{single_subjec-t)-

Then, the semantic function single_subject would be evaluated every time

that this grammar rule was applied by the parser, and the <q_subject>

phrase . added to the parsing graph would be the evaluated I ist of subjects. Note that in contrast to semantic functions, one of which must exist for each non-terminal of the lhs, each rule has but a single condition function.

Typ i ca I uses of condition functions are to make more comp I ex feature checks than those al lowed by the rule specification (e.g., requiring a certain phrase with either one or another feature set), to compute a set of features for a lhs phrase that is not specifiable in the rule {e.g., depending on the carried over features of more than one rhs phrase}, or to perform transformations of greater depth or complexity than those.al lowed by the rule. The capabi I ities of the rule statement are al I constrained by the design requirement that they be implemented very efficiently. When more complex syntactic processing is required, the condition function is used.

Some investigators have made much of the ab i I i ty to eva I ua te semantic information while the syntax analysis is proceeding, to reduce syntactic ambiguity {e.g., [Winograd

1972]}.

Although this is often

an

expensive strateg\d when semantic operations are ·1engthy, one possible use of the condition function {demonstrated above} is to evaluate some or a I I phrases before· the syntactic ana I ys is is comp I ete.

Because the condition function has access to the complete

environment of the parser, it can introduce arbitrary side effects.

However, this is generally not useful, and it is very harmful to the notion of I i ngu is tic s true ture imposed by an exp I i c i t grammar.

Efficiency considerations sometimes dictate such a use of condition functions: scanning a ~tring of digits and converting them to a

<number>, and a simple lexical analysis of the input string are two common uses of condition functions with significant side effects.

Dalam dokumen lment of the Requirements for the Degree of (Halaman 111-114)