next up previous contents
Next: Statements Up: Definition of the Programming Previous: The Constant Definition   Contents

Rules


$$ Rule ::= Rule-Type Rule-Name "(" Variable {"," Variable} ")" ":"
$$          {Statement} "end" [Rule-Type] [Rule-Name] ";" .
$$ Rule-Type ::= "allo_rule" | "combi_rule" | "end_rule" | "pruning_rule"
$$               "robust_rule" | "input_filter" | "output_filter" | "subrule" .

A rule is a sequence of statements that is executed as a unit:

combi_rule name ( $param1, $param2, $...$):
         statement1
         statement2
        $...$
end name;

A rule has to begin with one of the keywords allo_rule, combi_rule, end_rule, pruning_rule, robust_rule, input_filter, output_filter or subrule. It is followed by its parameter list, a list of variable names in parentheses. The variables will be assigned the parameter values when the rule is executed. The number of parameters depends on the rule type. The rule names have the following meanings:

`` allo_rule ( $lex_entry)'':
An allo-rule must occur exactly once in an allomorph rule file. It analyses a lexical entry and must generate one or more allomorph entries (via result). An allomorph rule has one parameter, namely the lexicon entry.
`` combi_rule ( $start, $next, $surf, $index)'':
Any number of combi-rules may occur in a combi-rule file. Before processing such a rule, the next segment (either the next allomorph or the next word form) is being read. The first parameter is the Start category, the second is the Next category, the third is the Next surface, and the fourth is the Next index. The third and the fourth parameter are optional. A combi-rule may state a successor rule set or accept the analysed input (both via result).
`` pruning_rule ( $list)'':
A pruning-rule may occur at most once in a syntax rule file. During syntax analysis, it can decide which states are still valid and which are to be deleted. The parameter is a list of categories of the states that have consumed the same input so far. The pruning-rule must execute a return statement with a list of yes- and no-symbols. Each state in $list corresponds to a symbol in the result list. If the symbol is yes, the corresponding state is preserved. If the symbol is no, the state is abandoned.
`` robust_rule ( $surface)'':
A robust-rule can only appear at most once a morphology rule file. If robust analysis has been switched on by the robust command, and a word form could not be recognised by the combi-rules, the robust-rule is executed with the surface of the word form as its parameter. A robust-rule can accept the word form via result.
`` input_filter ( $cat_list)'':
An input-filter may occur at most once in a syntax rule file. The input-filter is called after a word form has been analysed. It gets one parameter, namely the list of the analysis results, and it transforms it to one or more filtered results (via result).
`` output_filter ( $cat_list)'':
An output-filter may occur at most once in any rule file.
In allo-rule files:
The output-filter is called after all lexicon entry have been processed by the allo-rules. The filter is called for every allomorph surface. It gets one parameter, namely the list of the generated categories with that surface, and it transforms it to one or more filtered allomorph categories (via result).
In combi-rule files:
The output-filter is called after an item has been analysed. It gets one parameter, namely the list of the analysis results, and it transforms it to one or more filtered results (via result).
`` subrule ( $param1, $param2, $...$)'':
Any number of subrules may occur in any rule file. A subrule can be invoked from other rules and it must return a value to this rule via return. It can have any number of parameters (at least one).

If a rule is executed, all statements in the rule are processed sequentially. After that, the rule execution is terminated. Thereby, the if statement, the foreach statement, and the parallel statement may change the processing order. Special conditions apply if:

  1. A condition in a test statement does not hold. In this case the processing of the rule path is terminated. This is not an error.
  2. The fail statement was executed. This is a special case of case 1.
  3. An assert condition does not hold. In this case the processing of the whole grammar is terminated and an error message is displayed. This rule termination can be used to find categorisation or programming flaws in the rule system or in the lexicon.
  4. The error statement was executed. This is a special case of case 3.
  5. The return statement was executed in a subrule or in a pruning rule. In a subrule, this terminates the subrule int the current rule path and immediately returns to the calling rule. In a pruning rule, this terminates the pruning rule.


next up previous contents
Next: Statements Up: Definition of the Programming Previous: The Constant Definition   Contents
Bjoern Beutel