Feature Grammar rule formatting Some general rule writing guidelines are:
The first line must specify the start symbol for the grammar (e.g. what the root node should be called). Each rule should be on a separate line. Lines that begin with # are comments and rules in these lines are not used by the grammar. Blank lines are simply ignored. Do not use plus signs as they have a special significance to the parser internals. Each rule should have only one delimiter symbol (->). Lexical rules Here's an example lexical rule:
A -> 'fuzzy'
Lexical rules should adhere to the following guidelines:
Lexical rules should use an arrow (->), like syntactic rules, to separate part of speech labels from words. Words must be indicated using single quotes. Multiple words can be specified for a single part of speech using a pipe symbol (|) Features can be specified using a nested structure on the left hand side of the rule.
Feature values must be enclosed in single quotes. N[NUM='PL', PERS='3', ANIM='True'] = 'lions'
Syntactic rules
Both syntactic rules (->) to separate mothers from daughters. Rules should be of the formMother -> Daughter1 Daughter2 Daughter3 ...
Notice that the daughters are separated by spaces. If you specify terms on the right of the -> they all must be specified on the left hand side of one of your other rules. There is currently no way to indicate repetition or optionality. This is a target for a future release A pipe symbol (|) can be used to indicate a series of rules that all share a mother. Features can be specified for both mother and daughters using a bracketing structure to the right of the symbol. NP[NUM='SG', PERS='3'] -> D[NUM='SG',PERS='3'] N[NUM='SG',PERS='3']
Features can also use variables. Variables consist of a question mark followed by a variable name.
For example if you wanted to indicate that the person features should be shared between
the mother and the daughters, you could do the following: NP[NUM='SG', PERS=?pers] = D[NUM='SG', PERS=?pers] N[NUM='SG', PERS=?pers]
For feedback or bug reports, contact ksteimel@iu.edu
The code can be found here