module Parsetree: sig end
Functions used to recover the parse tree from a chart used to parse a
sentence.
Author(s): Daniel M. Albro
Version: $Revision$
Since 12/20/02 - [da]: Initial Creation.
type parse_cat =
| |
ParseTerminal of string |
(* | A terminal (name) | *) |
| |
ParseNonTerminal of string * int * int array |
(* | A non-terminal (name, id, states) | *) |
Categories of a parse tree
type parse_rhs =
| |
ParseRhs of parse_node list |
(* | list of child nodes | *) |
The branches of a parse tree
type parse_node =
| |
ParseNode of parse_cat * parse_rhs list |
(* | node in a parse tree (category of mother,
list of alternatives for descendants) | *) |
An actual parse tree or subtree
val print_parse_tree : parse_node -> unit
Outputs a parse tree in human-readable format
Returns nothing
tree
: Tree to output
val print_item : int -> Chart.subitem -> Grammar.grammar -> unit
Output a human-readable representation of a chart item
Returns nothing
cat
: Category of item to print
subitem
: States of item to print
g
: The relevant grammar
val lookup_matches : int ->
Chart.subitem -> Chart.chart -> Grammar.grammar -> int -> Chart.subitem list
Looks in the chart (sort of) for items that match <cat,item>,
which can be a template specification (that is, some elements of
item can be negative numbers, where -1 represents a wildcard and
<-1 represents a variable (the variables are actually looked for
directly in the chart). Also looks up any empty category items
which might match, since they aren't actually in the chart.
Returns list of items that match the specification <cat
,item
>
cat
: Category of item to look for
item
: Array of states (that is, covered sentence positions)
of item to look for.
ch
: Chart to look in
g
: Grammar being used to parse a sentence
sl
: Length of sentence being parsed
val recover_parse_tree : Grammar.grammar -> int -> Chart.chart -> parse_node
Recovers the parse tree for a successful parse of a sentence of
length sl using grammar g, where the parse produced the
chart ch. If the parse was not actually successful, raises Not_found. Otherwise, returns a parse node.
Raises Not_found
if the parse had not actually been successful.
Returns parse tree representing the sentence parsed
g
: Relevant grammar
sl
: Length of sentence that was parsed
ch
: Chart that was used to parse the sentence