sem.graph
Class Graph

java.lang.Object
  extended by sem.graph.Graph
All Implemented Interfaces:
java.lang.Cloneable

public class Graph
extends java.lang.Object
implements java.lang.Cloneable

Graph structure.


Field Summary
static Node ellip
          Node for representing ellipes in the graph.
static Node nil
          Node for representing missing nodes.
 
Constructor Summary
Graph()
          Create new graph.
 
Method Summary
 Edge addEdge(Edge e)
          Add a new edge to the graph.
 Edge addEdge(java.lang.String label, Node head, Node dep)
          Create and add a new edge.
 Node addNode(Node n)
          Add a new node to the graph.
 Node addNode(java.lang.String lemma, java.lang.String pos)
          Create and add a new node.
 Graph clone()
          Create a new independent graph with identical nodes and edges.
 java.util.ArrayList<Edge> getEdges()
          Get the list of edges in this graph.
 java.util.HashMap<java.lang.String,java.lang.String> getMetadata()
          Get the HashMap containing all metadata.
 java.lang.String getMetadata(java.lang.String key)
          Get metadata from the graph.
 java.util.ArrayList<Node> getNodes()
          Get the list of nodes in this graph.
 boolean hasMetadata()
          Check whether the graph has any metadata attached.
 void print()
          Print the graph information into standard output.
 void putMetadata(java.lang.String key, java.lang.String value)
          Add metadata to the graph.
 java.lang.String toString()
          Create a string representation of the graph.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ellip

public static Node ellip
Node for representing ellipes in the graph.


nil

public static Node nil
Node for representing missing nodes. For example, passive verbs in RASP are represented as an edge without a dependent.

Constructor Detail

Graph

public Graph()
Create new graph.

Method Detail

getNodes

public java.util.ArrayList<Node> getNodes()
Get the list of nodes in this graph.

Returns:
Nodes

getEdges

public java.util.ArrayList<Edge> getEdges()
Get the list of edges in this graph.

Returns:
Edges

addNode

public Node addNode(Node n)
Add a new node to the graph.

Parameters:
n - Node to be added.
Returns:
Node that was added.

addNode

public Node addNode(java.lang.String lemma,
                    java.lang.String pos)
Create and add a new node.

Parameters:
lemma - Lemma
pos - POS
Returns:
The new node that was added.

addEdge

public Edge addEdge(Edge e)
Add a new edge to the graph.

Parameters:
e - Edge.
Returns:
The edge that was added.

addEdge

public Edge addEdge(java.lang.String label,
                    Node head,
                    Node dep)
Create and add a new edge.

Parameters:
label - Label of the edge.
head - Head node of the edge.
dep - Dependent node of the edge.
Returns:
The edge that was added.

putMetadata

public void putMetadata(java.lang.String key,
                        java.lang.String value)
Add metadata to the graph. The graph contains a hashmap which the reader can use to store various information. For example: putData("orig", "This is the original sentence before parsing"); The data can then be retrieved using the getMetadata() method.

Parameters:
key - Key
value - Value
See Also:
getMetadata

getMetadata

public java.lang.String getMetadata(java.lang.String key)
Get metadata from the graph.

Parameters:
key - Key
Returns:
Value
See Also:
putMetadata

getMetadata

public java.util.HashMap<java.lang.String,java.lang.String> getMetadata()
Get the HashMap containing all metadata.

Returns:
Hashmap with the metadata.

hasMetadata

public boolean hasMetadata()
Check whether the graph has any metadata attached.

Returns:
True if there is metadata, false otherwise.

print

public void print()
Print the graph information into standard output.


toString

public java.lang.String toString()
Create a string representation of the graph.

Overrides:
toString in class java.lang.Object

clone

public Graph clone()
Create a new independent graph with identical nodes and edges.

Overrides:
clone in class java.lang.Object