Module Grammar


module Grammar: sig  end
Represents an N-Multiple Context Free Grammar in something like Chomsky-Normal Form (rules have one terminal or one or two nonterms.)
Author(s): Daniel M. Albro
Version: $Revision$
Since 11/21/02 - [da]: Initial Creation.

class rule : object  end
This consists of a head category, one or two right-hand categories, and a map function, here just the index of the map function in the grammar's list of map functions.
class rule_pat : int -> int -> int -> int array -> bool -> object  end
A rule pattern will be stored in a list pertaining to a particular category (the "trigger" category).
class reconstruct_pat : int -> int array -> object  end
Rule reconstruction pattern (used to reconstruct parse trees; one such pattern exists for every rule, more or less).

type map_item = int * int
Pair: RHS index, element index


type mapfunc = map_item list array
String map function for MCFGs

val is_terminal : rule -> bool
Returns whether rule r is a terminal one or not, that is, whether the right hand side is a terminal element.

r : Rule being checked
exception Duplicate_category
Raised when a grammar being built has two different arities for the same category.
exception Unknown_terminal of string
Raised if a terminal_id is looked up for a terminal that doesn't exist. This typically happens when trying to parse a sentence with some vocabulary not mentioned in the grammar.
class grammar : object  end
This represents a Multiple Context-Free Grammar and all of the information we've managed to wring out of it.