next up previous contents
Next: Grammar Rules Up: Phrase Structure Grammars Previous: Empty Categories   Contents


ALE Lexical Rules

[Reference Manual]
[Code]
Lexical rules provide a mechanism for expressing redundancies in the lexicon, such as the kinds of inflectional morphology used for word classes, derivational morphology as found with suffixes and prefixes, as well as zero-derivations as found with detransitivization, nominalization of some varieties and so on. The format ALE provides for stating lexical rules is similar to that found in both PATR-II and HPSG.

In order to implement them efficiently, lexical rules, as well as their effects on lexical entries, are compiled in much the same way as grammars. To enhance their power, lexical rules, like grammar rules, allow arbitrary procedural attachment with ALE definite constraints.

The lexical rule system of ALE is productive in that it allows lexical rules to apply sequentially to their own output or the output of other lexical rules. Thus, it is possible to derive the nominal runner from the verb run, and then derive the plural nominal runners from runner, and so on. At the same time, the lexical system is leashed to a fixed depth-bound, which may be specified by the user. This bound limits the number of rules that can be applied to any given category. The bound on application of rules is specified by a command such as the following, which should appear somewhere at the beginning of the input file:

  :-lex_rule_depth(2).
Of course, bounds other than 2 can be used. The bound indicates how many applications of lexical rules can be made, and may be 0. If there is more than one such specification in an input file, the last one will be the one that is used. If no specification is given, the default is 2.

The format for lexical rules is as follows:

  <lex_rule> ::= <lex_rule_name> lex_rule <lex_rewrite> 
                                 morphs <morphs>.

  <lex_rewrite> ::= <desc> **> <desc>
                  | <desc> **> <desc> if <goal>

  <morphs> ::= <morph>
             | <morph>, <morphs>

  <morph> ::= (<string_pattern>) becomes (<string_pattern>)
            | (<string_pattern>) becomes (<string_pattern>) 
                                 when <prolog_goal>

  <string_pattern> ::= <atomic_string_pattern>
                     | <atomic_string_pattern>, <string_pattern>
  
  <atomic_string_pattern> ::=  <atom>
                            |  <var>
                            |  <list(<var_char>)>
  <var_char> ::= <char>
               | <var>
An example of a lexical rule with almost all of the bells and whistles (we put off procedural attachment for now) is:
plural_n lex_rule  
  (n,
   num:sing)
   **> (n,
        num:plu)
  morphs
    goose becomes geese,
    [k,e,y] becomes [k,e,y,s],
    (X,man) becomes (X,men),
    (X,F) becomes (X,F,es) when fricative(F),
    (X,ey) becomes (X,[i,e,s]),
    X becomes (X,s).

  fricative([s]).
  fricative([c,h]).
  fricative([s,h]).
  fricative([x]).
We will use this lexical rule to explain the behavior of the lexical rule system. First note that the name of a lexical rule, in this case plural_n, must in general be a Prolog atom. Further note that the top-level parentheses around both the descriptions and the patterns are necessary. If the Prolog goal, in this case fricative(F), had been a complex goal, then it would need to be parenthesized as well. The next thing to note about the lexical rule is that there are two descriptions -- the first describes the input category to the rule, while the second describes the output category. These are arbitrary descriptions, and may contain disjunctions, macros, etc. We will come back to the clauses for fricative/1 shortly. Note that the patterns in the morphological component are built out of variables, sequences and lists. Thus a simple rewriting can be specified either using atoms as with goose above, with a list, as in [k,e,y], or with a sequence as in (X,man), or with both, as in (X,[i,e,s]). The syntax of the morphological operations is such that in sequences, atoms may be used as a shorthand for lists of characters. But lists must consist of variables or single characters only. Thus we could not have used (X,[F]) in the fricative case, as F might is itself a complex list such as [s,h] or [x]. But in general, variables ranging over single characters can show up in lists.

The basic operation of a lexical rule is quite simple. First, every lexical entry, including a word and a category, that is produced during compilation is checked to see if its category satisfies the input description of a lexical rule. If it does, then a new category is generated to satisfy the output description of the lexical rule, if possible. Note that there might be multiple solutions, and all solutions are considered and generated. Thus multiple solutions to the input or output descriptions lead to multiple lexical entries.

After the input and output categories have been computed, the word of the input lexical entry is fed through the morphological analyzer to produce the corresponding output word. Unlike the categorial component of lexical rules, only one output word will be constructed, based on the first input/output pattern that is matched.6.1The input word is matched against the patterns on the left hand side of the morphological productions. When one is found that the input word matches, any condition imposed by a when clause on the production is evaluated. This ordering is imposed so that the Prolog goal will have all of the variables for the input string instantiated. At this point, Prolog is invoked to evaluate the when clause. In the most restricted case, as illustrated in the above lexical rule, Prolog is only used to provide abbreviations for classes. Thus the definition for fricative/1 consists only of unit clauses. For those unfamiliar with Prolog, this strategy can be used in general for simple morphological abbreviations. Evaluating these goals requires the F in the input pattern to match one of the strings given. The shorthand of using atoms for the lists of their characters only operates within the morphological sequences. In particular, the Prolog goals do not automatically inherit the ability of the lexical system to use atoms as an abbreviation for lists, so they have to be given in lists. Substituting fricative(sh) for fricative([s,h]) would not yield the intended interpretation. Variables in sequences in morphological productions will always be instantiated to lists, even if they are single characters. For instance, consider the lexical rule above with every atom written out as an explicit list:

    [g,o,o,s,e] becomes [g,e,e,s,e],
    [k,e,y] becomes [k,e,y,s],
    (X,[m,a,n]) becomes (X,[m,e,n]),
    (X,F) becomes (X,F,[e,s]) when fricative(F),
    (X,[e,y]) becomes (X,[i,e,s]),
    X becomes (X,[s]).
In this example, the s in the final production is given as a list, even though it is only a single character.

The morphological productions are considered one at a time until one is matched. This ordering allows a form of suppletion, whereby special forms such as those for the irregular plural of goose and key to be listed explicitly. It also allows subregularities, such as the rule for fricatives above, to override more general rules. Thus the input word beach becomes beaches because beach matches (X,F) with X = [b,e,a] and F = [c,h], the goal fricative([c,h]) succeeds and the word beaches matches the output pattern (X,F,[e,s]), instantiated after the input is matched to ([b,e,a],[c,h],[e,s]). Similarly, words that end in [e,y] have this sequence replaced by [i,e,s] in the plural, which is why an irregular form is required for keys, which would otherwise match this pattern. Finally, the last rule matches any input, because it is just a variable, and the output it produces simply suffixes an [s] to the input.

For lexical rules with no morphological effect, the production:

  X becomes X
suffices. To allow lexical operations to be stated wholly within Prolog, a rule may be used such as the following:
  X becomes Y when morph_plural(X,Y)
In this case, when morph_plural(X,Y) is called, X will be instantiated to the list of the characters in the input, and as a result of the call, Y should be instantiated to a ground list of output characters.

We finally turn to the case of lexical rules with procedural attachments, as in the following (simplified) example from HPSG:

extraction lex_rule
  local:(cat:(head:H,
              subcat:Xs),  
         cont:C),
  nonlocal:(to_bind:Bs,
            inherited:Is)
  **> local:(cat:(head:H,
                  subcat:Xs2),
             cont:C),
      nonlocal:(to_bind:Bs,
                inherited:[G|Is])
  if 
    select(G,Xs,Xs2)
  morphs
    X becomes X.

  select(X,(hd:X),Xs) if true.
  select(X,[Y|Xs],[Y|Ys]) if
    select(X,Xs,Ys).
This example illustrates an important point other than the use of conditions on categories in lexical rules. The point is that even though only the LOCAL CAT SUBCAT and NONLOCAL INHERITED paths are affected, information that stays the same must also be mentioned. For instance, if the cont:C specification had been left out of either the input our output category description, then the output category of the rule would have a completely unconstrained content value. This differs from the default-based nature of the usual presentation of lexical rules, which assumes all information that hasn't been explicitly specified is shared between the input and the output. As another example, we must also specify that the HEAD and TO_BIND features are to be copied from the input to the output; otherwise there would be no specification of them in the output of the rule. This fact follows from the description of the application of lexical rules: they match a given category against the input description and produce the most general category(s) matching the output description.

Turning to the use of conditions in the above rule, the select/3 predicate is defined so that it selects its first argument as a list member of its second argument, returning the third argument as the second argument with the selected element deleted. In effect, the above lexical rule produces a new lexical entry which is like the original entry, except for the fact that one of the elements on the subcat list of the input is removed from the subcat list and added to the inherited value in the output. Nothing else changes.

Procedurally, the definite clause is invoked after the lexical rule has matched the input description against the input category. Like the morphological system, this control decision was made to ensure that the relevant variables are instantiated at the time the condition is resolved. The condition here can be an arbitrary goal, but if it is complex, there should be parentheses around the whole thing. Cuts should not be used in conditions on lexical rules (see the comments on cuts in grammar rules below, which also apply to cuts in lexical rules).

Currently, ALE does not check for redundancies or for entries that subsume each other, either in the base lexicon or after closure under lexical rules. ALE also does not apply lexical rules to empty categories.


next up previous contents
Next: Grammar Rules Up: Phrase Structure Grammars Previous: Empty Categories   Contents
TRALE User's Manual