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).
exception Ununifiable
raised when a unification fails
val separate_variables : Chart.subitem -> Chart.subitem -> unit
Bump up variable numbers in item to keep them distinct from variables in the search item sitem
Returns nothing

item : Trigger item, item to have variables renumbered
sitem : Item to look for, item we're unifying with
val unify : Chart.subitem -> Chart.subitem -> Chart.subitem
Checks whether two items are unifiable, and unifies them. Makes a copy of item2 rather than modifying it.
Returns unification of the two items (basically item1 filled out)

item1 : First item to unify; assumed to have been retrieved out of the chart; that is, it must have no -1 states.
item2 : Second item to unify, Make have -1 states.

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.