index
module components.merging.sputlink.objects
Constraint
Edge
Node
class Constraint
Inherits from: object
An object representing the constraint on an edge.
Instance variables:
node1 - an eiid or tid
node2 - an eiid or tid
relset - a string
edge - the Edge the constraint is expressed on
cycle - an integer, the closure cycle in which the constraint was created
source -
graph -
history -
Public Functions
__init__(self, id1, rels, id2, cycle=None, source=None, history=None)
__str__(self)
get_node1(self)
Retrieve the node1 object from the edge.
get_node2(self)
Retrieve the node2 object from the edge.
has_normalized_relation(self)
Return True if the relation is one of the normalized ones, return
False otherwise.
has_simple_relation(self)
Return True if the relation is one of the non-disjunctive ones,
return False otherwise.
history_string(self)
is_disjunction(self)
Return True if the relation set is a disjunction, return False
otherwise.
is_garbage(self)
Return True if the constraint is useless and potentially damaging to the
algorithm. We don't like constraints like [e1 < e1].
pp_history(self, indent='')
class Edge
Inherits from: object
Implements the edges of the graph.
Instance variables:
id - the node identifier
node1 - an eiid, tid or other identifier
node2 - an eiid, tid or other identifier
graph - the Graph the edge is in
constraint - None or the current Constraint on the edge
relset - None or the value of constraint.relset
constraints - history of Constraints, a list
Public Functions
__init__(self, n1, n2, graph)
Initialize from two node identifiers and the graph.
__str__(self)
add_constraint(self, constraint)
Set the constaint attribute and append to the constraints
attribute.
get_node1(self)
retrun the Node object for node1.
get_node2(self)
retrun the Node object for node2.
is_derived(self)
Returns True if the constraint on the edge was derived by closure.
remove_constraint(self)
Remove the constraint from the edge. Also updates the edges_in and
edges_out attributes on the source and target node.
class Node
Inherits from: object
Implements the node objects of the graph.
Instance variables:
id - an eiid, tid or other identifier
text - string from the document or empty string
source - a Tag or an identifier
source-type - 'TIMEX3', 'EVENT', or 'IDENTIFIER'
edges_in - a hash indexed on node ids
edges_out - a hash indexed on node ids
The source and source-type attributes encode what element or elements the
Node was created from. If source-type is TIMEX or EVENT then source is a
single tag.
But if source-type is 'class', then the Node implements an equivalence set
of time expressions and events, that is, a set defined by the = interval
relation. The source attribute than is a list of tuples, where each tuple
contains (i) a Tag, (ii) a pair of interval relation and TimeML relation,
and (iii) another XmlDocElement or pair of XmlDocElements. The very first
Node in the entire list is the class representative. (TODO: is this still
relevant?)
Public Functions
__init__(self, source, identifier, source_type, text)
Initialize from a timex, an event or simply an identifier, using tid,
eiid or the identifier for the node identifier. Set edges_in and
edges_out to the empty hash.
__str__(self)
Returns string in "<Node id text>" format.
pretty_print(self)
Print the node with its edges_in and edges_out attributes to standard
output.