Package edu.fiu.jtlex.data
Class Graph
java.lang.Object
edu.fiu.jtlex.data.Graph
Default implementation of
IGraph.
Represents a TimeML Graph.
A TimeML temporal graph is a graph T = (V,E)
where: V is a set of temporal events and time expressions. E is a set of
TimeML links: a tuple (u,v,w) where u, v belong to V and w is a link type.
There are 25 link types, refer to
TLinkType,
ALinkType, and
SLinkType.
A graph is represented with two Hash Tables, one for Nodes and one for Links.
- Author:
- Luis Robaina
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.fiu.jtlex.data.IGraph
IGraph.GraphType -
Constructor Summary
ConstructorsConstructorDescriptionGraph()Generates a blank graph object for manual computation.Generates a graph based on a TimeML annotated text file.Graph(InputStream timeMLData)Generates a graph based on a TimeML annotated text file.Generates a graph based on a TimeML annotated text file. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddLink(int NodeOneID, int NodeTwoID, ILink.LinkTag linktag, ILinkType linkType, String syntax, ISignal signal, ILink.Origintype orig)Adds aLinkinto the graph, givenNodeidentification numbers.booleanAdds aLinkinto the graph.booleanaddLink(INode NodeOne, INode NodeTwo, ILink.LinkTag linktag, ILinkType linkType, String syntax, ISignal signal, ILink.Origintype orig)Adds aLinkinto the graph, givenNodeobjects.booleanAdds a node to the graph.clone()booleancontainsLink(ILink link)Return true if the given link exists in the graph.booleanReturns the set of consistent subordinate subgraphs.Returns the type of graph.Returns the set of inconsistent subordinate subgraphs.Returns a list of Indeterminant Time Pairs.getLinks()Returns a set with all the Links in the TimeML graph, (null) if the TimeML graph is empty.intReturns the number of links.Returns the count of each type of links, formatted as a string.getNodeByID(int NodeID)Returns a INode reference if a node with ID NodeID exists in the graph returns null otherwise.getNodes()Returns a set with all the Nodes in the TimeML graph, (null) if the TimeML graph is empty.intReturns the number of nodes.Returns the set of subordination links.Returns the set of subordinate subgraphs.Return the string representations of timeline solututions viaGraphTCSP.stringTimeLine().Returns the computed timeline.booleanReturns true if the graph is consistent.removeLink(ILink link)Removes the given link from the graph.removeNode(INode node)Removes a node object from the graph.removeNodeByID(int ID)Removes a node from the graph, by node identification number.voidsetConsistency(boolean consistency)Sets the consistency of the graph.voidsetGraphType(IGraph.GraphType graphType)Sets the type of graph toIGraph.GraphType.MainGraphorIGraph.GraphType.SubbordinationGraphvoidsetIndeterminantTimePairs(ArrayList<String> iTimePairs)Sets the Indeterminant Time Pairs for the current Graph.voidsetTimeline(Timeline newTimeline)Sets the Timeline of the current Graph.toJSON()Returns the JSON (RFC 8259) representation of the Graph.toString()
-
Constructor Details
-
Graph
public Graph()Generates a blank graph object for manual computation. Nodes and links must be added via theaddNode(INode)andaddLink(INode, INode, LinkTag, ILinkType, String, ISignal, Origintype)functions, respectively.- See Also:
IGraph
-
Graph
Generates a graph based on a TimeML annotated text file. This constructor:- converts the File object into a FileStream
- parses the text file via
TimeMLParser.parse(InputStream) - adds the parsed Timex nodes, Instance nodes, and Links
- finds the subordinate partitions via
Partitioner.partitionGraph(IGraph) - finds inconsistent subgraphs via
InconsistencyDetector.isConsistent(IGraph) - finds indeterminacies via
IndeterminacyDetector.detect(IGraph) - builds the Timeline object via
GraphTCSP.stringTimeLine()
- Parameters:
timeMLFile- The TimeML file to be analyzed.- Throws:
FileNotFoundException- if there is a problem reading the given file.- See Also:
TimeMLParser,Partitioner,InconsistencyDetector,IndeterminacyDetector,GraphTCSP,Timeline
-
Graph
Generates a graph based on a TimeML annotated text file. This constructor:- converts the String object into an InputStream
- parses the text file via
TimeMLParser.parse(InputStream) - adds the parsed Timex nodes, Instance nodes, and Links
- finds the subordinate partitions via
Partitioner.partitionGraph(IGraph) - finds inconsistent subgraphs via
InconsistencyDetector.isConsistent(IGraph) - finds indeterminacies via
IndeterminacyDetector.detect(IGraph) - builds the Timeline object via
GraphTCSP.stringTimeLine()
- Parameters:
timeMLString- The TimeML string to be analyzed.- See Also:
TimeMLParser,Partitioner,InconsistencyDetector,IndeterminacyDetector,GraphTCSP,Timeline
-
Graph
Generates a graph based on a TimeML annotated text file. This constructor:- parses the text file via
TimeMLParser.parse(InputStream) - adds the parsed Timex nodes, Instance nodes, and Links
- finds the subordinate partitions via
Partitioner.partitionGraph(IGraph) - finds inconsistent subgraphs via
InconsistencyDetector.isConsistent(IGraph) - finds indeterminacies via
IndeterminacyDetector.detect(IGraph) - builds the Timeline object via
GraphTCSP.stringTimeLine()
- Parameters:
timeMLData- The TimeML InputStream to be analyzed.- See Also:
TimeMLParser,Partitioner,InconsistencyDetector,IndeterminacyDetector,GraphTCSP,Timeline
- parses the text file via
-
-
Method Details
-
getLinksCount
public int getLinksCount()Description copied from interface:IGraphReturns the number of links.- Specified by:
getLinksCountin interfaceIGraph- Returns:
- the number of links.
-
getNodesCount
public int getNodesCount()Description copied from interface:IGraphReturns the number of nodes.- Specified by:
getNodesCountin interfaceIGraph- Returns:
- the number of nodes.
-
getNodeByID
Description copied from interface:IGraphReturns a INode reference if a node with ID NodeID exists in the graph returns null otherwise.- Specified by:
getNodeByIDin interfaceIGraph- Parameters:
NodeID- : An Integer ID for a given node.- Returns:
- A INode reference if a node with ID NodeID exists in the graph returns null otherwise.
-
addLink
Description copied from interface:IGraphAdds aLinkinto the graph. -
addLink
public boolean addLink(INode NodeOne, INode NodeTwo, ILink.LinkTag linktag, ILinkType linkType, String syntax, ISignal signal, ILink.Origintype orig)Description copied from interface:IGraphAdds aLinkinto the graph, givenNodeobjects.- Specified by:
addLinkin interfaceIGraph- Parameters:
NodeOne- The firstNode. This is referred to as theEvent Instance.NodeTwo- The secondNode. This is referred to as theRelated to Event.linktag- The type of link (TLink, ALink, SLink)linkType- TODO: (document) explain the necessity of both ILinkType and linktag as parameters in this method.syntax- the syntactic pattern that was used in generating the linksignal- ID of the signal, if the temporal relation is explicitly signaled in the text.orig- whether a TLink was generated manually or by closure.- Returns:
- True on successful insertion, False if link already exists.
-
addLink
public boolean addLink(int NodeOneID, int NodeTwoID, ILink.LinkTag linktag, ILinkType linkType, String syntax, ISignal signal, ILink.Origintype orig)Description copied from interface:IGraphAdds aLinkinto the graph, givenNodeidentification numbers.- Specified by:
addLinkin interfaceIGraph- Parameters:
NodeOneID- The firstNodeID. This is referred to as theEvent Instance.NodeTwoID- The secondNodeID. This is referred to as theRelated to Event.linktag- The type of link (TLink, ALink, SLink)linkType- TODO: (document) explain the necessity of both ILinkType and linktag as parameters in this method.syntax- the syntactic pattern that was used in generating the linksignal- ID of the signal, if the temporal relation is explicitly signaled in the text.orig- whether a TLink was generated manually or by closure.- Returns:
- True on successful insertion, False if link already exists.
-
containsLink
Description copied from interface:IGraphReturn true if the given link exists in the graph.- Specified by:
containsLinkin interfaceIGraph- Parameters:
link- the link to find.- Returns:
- true if the given link exists in the graph.
-
removeLink
Description copied from interface:IGraphRemoves the given link from the graph.- Specified by:
removeLinkin interfaceIGraph- Parameters:
link- the link to remove.- Returns:
- the link that was removed, Null if link was not found.
-
addNode
Description copied from interface:IGraphAdds a node to the graph. -
removeNode
Description copied from interface:IGraphRemoves a node object from the graph.- Specified by:
removeNodein interfaceIGraph- Parameters:
node- the node object to remove.- Returns:
- the node that was removed, Null if node was not found.
-
removeNodeByID
Description copied from interface:IGraphRemoves a node from the graph, by node identification number.- Specified by:
removeNodeByIDin interfaceIGraph- Parameters:
ID- the identification number of the node to be removed.- Returns:
- the node that was removed, Null if node was not found.
-
setConsistency
public void setConsistency(boolean consistency)Description copied from interface:IGraphSets the consistency of the graph.- Specified by:
setConsistencyin interfaceIGraph- Parameters:
consistency- the consistency of the graph.
-
getLinks
Description copied from interface:IGraphReturns a set with all the Links in the TimeML graph, (null) if the TimeML graph is empty. -
getNodes
Description copied from interface:IGraphReturns a set with all the Nodes in the TimeML graph, (null) if the TimeML graph is empty. -
getLinkTypesCount
Description copied from interface:IGraphReturns the count of each type of links, formatted as a string.- Specified by:
getLinkTypesCountin interfaceIGraph- Returns:
- the count of each type of links, formatted as a string.
-
getGraphType
Description copied from interface:IGraphReturns the type of graph.- Specified by:
getGraphTypein interfaceIGraph- Returns:
- the type of graph.
- See Also:
IGraph.GraphType
-
setGraphType
Description copied from interface:IGraphSets the type of graph toIGraph.GraphType.MainGraphorIGraph.GraphType.SubbordinationGraph- Specified by:
setGraphTypein interfaceIGraph- Parameters:
graphType- the type of graph.- See Also:
IGraph.GraphType
-
getPartitions
Description copied from interface:IGraphReturns the set of subordinate subgraphs.- Specified by:
getPartitionsin interfaceIGraph- Returns:
- the set of subordinate subgraphs.
- See Also:
Partitioner.partitionGraph(IGraph)
-
getConsistentPartitions
Description copied from interface:IGraphReturns the set of consistent subordinate subgraphs.- Specified by:
getConsistentPartitionsin interfaceIGraph- Returns:
- the set of consistent subordinate subgraphs.
- See Also:
InconsistencyDetector
-
getInconsistentPartitions
Description copied from interface:IGraphReturns the set of inconsistent subordinate subgraphs.- Specified by:
getInconsistentPartitionsin interfaceIGraph- Returns:
- the set of inconsistent subordinate subgraphs.
- See Also:
InconsistencyDetector
-
getSolutionList
Description copied from interface:IGraphReturn the string representations of timeline solututions viaGraphTCSP.stringTimeLine().- Specified by:
getSolutionListin interfaceIGraph- Returns:
- the string representations of timeline solututions
via
GraphTCSP.stringTimeLine().
-
getPartitionlinks
Description copied from interface:IGraphReturns the set of subordination links.- Specified by:
getPartitionlinksin interfaceIGraph- Returns:
- the set of subordination links.
-
getTimeline
Description copied from interface:IGraphReturns the computed timeline.- Specified by:
getTimelinein interfaceIGraph- Returns:
- the computed timeline.
- See Also:
GraphTCSP
-
getIndeterminantTimePairs
Description copied from interface:IGraphReturns a list of Indeterminant Time Pairs.- Specified by:
getIndeterminantTimePairsin interfaceIGraph- Returns:
- a list of Indeterminant Time Pairs.
-
setTimeline
Description copied from interface:IGraphSets the Timeline of the current Graph.- Specified by:
setTimelinein interfaceIGraph- Parameters:
newTimeline- the new Timeline.
-
setIndeterminantTimePairs
Description copied from interface:IGraphSets the Indeterminant Time Pairs for the current Graph.- Specified by:
setIndeterminantTimePairsin interfaceIGraph- Parameters:
iTimePairs- the list of Indeterminant Time Pairs.- See Also:
IndeterminacyDetector.detect(IGraph),IndeterminacyDetector.indeterminantTimePairs()
-
isConsistent
public boolean isConsistent()Description copied from interface:IGraphReturns true if the graph is consistent.- Specified by:
isConsistentin interfaceIGraph- Returns:
- true if the graph is consistent.
-
clone
-
toString
-
equals
-
toJSON
Description copied from interface:IGraphReturns the JSON (RFC 8259) representation of the Graph.
-