class documentation

class HoleSemantics(object): (source)

Constructor: HoleSemantics(usr)

View In Hierarchy

This class holds the broken-down components of a hole semantics, i.e. it extracts the holes, labels, logic formula fragments and constraints out of a big conjunction of such as produced by the hole semantics grammar. It then provides some operations on the semantics dealing with holes, labels and finding legal ways to plug holes with labels.

Method __init__ Constructor. usr' is a ``sem.Expression` representing an Underspecified Representation Structure (USR). A USR has the following special predicates: ALL(l,v,n), EXISTS(l,v,n), AND(l,n,n), OR(l,n,n), IMP(l,n,n), IFF(l,n,n), PRED(l,v,n,v[,v]*) where the brackets and star indicate zero or more repetitions, LEQ(n,n), HOLE(n), LABEL(n) where l is the label of the node described by the predicate, n is either a label or a hole, and v is a variable.
Method formula_tree Return the first-order logic formula tree for this underspecified representation using the plugging given.
Method is_node Return true if x is a node (label or hole) in this semantic representation.
Method pluggings Calculate and return all the legal pluggings (mappings of labels to holes) of this semantics given the constraints.
Instance Variable constraints Undocumented
Instance Variable fragments Undocumented
Instance Variable holes Undocumented
Instance Variable labels Undocumented
Instance Variable top_hole Undocumented
Instance Variable top_most_labels Undocumented
Method _break_down Extract holes, labels, formula fragments and constraints from the hole semantics underspecified representation (USR).
Method _find_top_hole Return the hole that will be the top of the formula tree.
Method _find_top_most_labels Return the set of labels which are not referenced directly as part of another formula fragment. These will be the top-most labels for the subtree that they are part of.
Method _find_top_nodes Undocumented
Method _formula_tree Undocumented
Method _plug_hole Try all possible ways of plugging a single hole. See _plug_nodes for the meanings of the parameters.
Method _plug_nodes Plug the nodes in `queue' with the labels in `potential_labels'.
Method _sanity_check_plugging Make sure that a given plugging is legal. We recursively go through each node and make sure that no constraints are violated. We also check that all holes have been filled.
Method _violates_constraints Return True if the `label' cannot be placed underneath the holes given by the set `ancestors' because it would violate the constraints imposed on it.
def __init__(self, usr): (source)

Constructor. usr' is a ``sem.Expression` representing an Underspecified Representation Structure (USR). A USR has the following special predicates: ALL(l,v,n), EXISTS(l,v,n), AND(l,n,n), OR(l,n,n), IMP(l,n,n), IFF(l,n,n), PRED(l,v,n,v[,v]*) where the brackets and star indicate zero or more repetitions, LEQ(n,n), HOLE(n), LABEL(n) where l is the label of the node described by the predicate, n is either a label or a hole, and v is a variable.

def formula_tree(self, plugging): (source)

Return the first-order logic formula tree for this underspecified representation using the plugging given.

def is_node(self, x): (source)

Return true if x is a node (label or hole) in this semantic representation.

def pluggings(self): (source)

Calculate and return all the legal pluggings (mappings of labels to holes) of this semantics given the constraints.

constraints = (source)

Undocumented

fragments: dict = (source)

Undocumented

Undocumented

Undocumented

top_hole = (source)

Undocumented

top_most_labels = (source)

Undocumented

def _break_down(self, usr): (source)

Extract holes, labels, formula fragments and constraints from the hole semantics underspecified representation (USR).

def _find_top_hole(self): (source)

Return the hole that will be the top of the formula tree.

def _find_top_most_labels(self): (source)

Return the set of labels which are not referenced directly as part of another formula fragment. These will be the top-most labels for the subtree that they are part of.

def _find_top_nodes(self, node_list): (source)

Undocumented

def _formula_tree(self, plugging, node): (source)

Undocumented

def _plug_hole(self, hole, ancestors0, queue, potential_labels0, plug_acc0, record): (source)

Try all possible ways of plugging a single hole. See _plug_nodes for the meanings of the parameters.

def _plug_nodes(self, queue, potential_labels, plug_acc, record): (source)

Plug the nodes in `queue' with the labels in `potential_labels'.

Each element of `queue' is a tuple of the node to plug and the list of ancestor holes from the root of the graph to that node.

`potential_labels' is a set of the labels which are still available for plugging.

`plug_acc' is the incomplete mapping of holes to labels made on the current branch of the search tree so far.

`record' is a list of all the complete pluggings that we have found in total so far. It is the only parameter that is destructively updated.

def _sanity_check_plugging(self, plugging, node, ancestors): (source)

Make sure that a given plugging is legal. We recursively go through each node and make sure that no constraints are violated. We also check that all holes have been filled.

def _violates_constraints(self, label, ancestors): (source)

Return True if the `label' cannot be placed underneath the holes given by the set `ancestors' because it would violate the constraints imposed on it.