|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object standup.joke.JokeGraph
public class JokeGraph
A JokeGraph
records all the internal structure of a
JokeStructure
, allowing us to inspect all the choices made by the
Generator
during the various stages of joke generation, i.e. schema
instantiation, output specification function clause instantiation, and
template filling.
Field Summary | |
---|---|
(package private) Hashtable<String,List<JokeGraphEdge>> |
adjacency
A Hashtable that stores all the JokeGraphEdge s in this
JokeGraph . |
static int |
CLAUSE_INSTANTIATON
|
private List<Keyword> |
clauseInstantiations
A List of keywords in this graph which arise during clause instantiation. |
(package private) int |
counter
A counter that ensures unique node label numbering. |
(package private) Hashtable<String,JokeGraphNode> |
nodes
A Hashtable that stores all the JokeGraphNode s in this
JokeGraph . |
static int |
SCHEMA_INSTANTIATON
|
private List<Keyword> |
schemaInstantiations
A List of keywords in this graph which arise during schema instantiation. |
Constructor Summary | |
---|---|
JokeGraph(Hashtable<String,JokeGraphNode> nodes,
Hashtable<String,List<JokeGraphEdge>> edges,
List<Keyword> schemaInstantiations,
List<Keyword> clauseInstantiations,
int nodeCounter)
This is the constructor used to build JokeGraphs from existing ones, e.g. |
|
JokeGraph(Schema s,
Bindings b)
This is the constructor used to create a JokeGraph during the schema instantiation phase. |
Method Summary | |
---|---|
(package private) void |
addEdge(String edgeLabel,
JokeGraphNode from,
JokeGraphNode to,
SourceProcess sp,
String sl)
|
private void |
addLexNode(Bindings bindings,
UnifiableVariable variable,
SourceProcess sourceProcessCode,
String sourceLabel)
Given a UnifiableVariable that is bound to a Keyword , it
creates a new JokeGraphNodeKeyword and replaces the binding of the
variable to the node instead. |
private void |
addPrecondition(UnifiableCompound instantiatedPrecond,
SourceProcess sp,
String sl)
Adds edges representing the given (instantiated) Precondition . |
private void |
addPreconditions(Bindings bindings,
List<Precondition> preconditions,
SourceProcess sourceProcess,
String sourceLabel)
Given a list of Precondition s, this method goes through them and
adds representations of them to this JokeGraph . |
(package private) String |
addTemplateNode(String parentTemplateNodeID,
String templateLabel,
int childNumber)
This method adds a node to the jokegraph that represents a template. |
private void |
addVars(Bindings b,
UnifiableListVar vars,
SourceProcess sourceProcessCode,
String sourceLabel)
This function adds a node to the jokegraph for a variable appearing in a lexical precondition, whether coming from a schema or a clause. |
JokeGraph |
copy()
Returns a copy of this JokeGraph . |
boolean |
equals(Object obj)
|
List<Keyword> |
getClauseInstantiations()
Returns a List of Keywords that arise during clause instantiation. |
Iterator<JokeGraphEdge> |
getEdges(JokeGraphNode node)
Returns the edges associated with the given JokeGraphNode as an
Iterator<JokeGraphNode> . |
private int |
getNextCount()
|
JokeGraphNode |
getNode(String nodeID)
Returns the node in this graph with the given ID. |
Iterator<JokeGraphNode> |
getNodes()
Returns the nodes in this JokeGraph as an
Iterator<JokeGraphNode> . |
List<Keyword> |
getSchemaInstantiations()
Returns a List of Keywords that arise during schema instantiation. |
int |
hashCode()
|
static JokeGraph |
readXML(Element e)
|
String |
toString()
|
void |
update(Clause c,
Bindings b)
Updates this JokeGraph with nodes and edges arising from this output specification function clause instantiation |
void |
writeXML(Writer out,
String indent)
This method writes the necessary information contained within an instance to an XML file. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
Hashtable<String,JokeGraphNode> nodes
Hashtable
that stores all the JokeGraphNode
s in this
JokeGraph
. The keys are the node labels, the values are the
JokeGraphNode
s themselves.
Hashtable<String,List<JokeGraphEdge>> adjacency
Hashtable
that stores all the JokeGraphEdge
s in this
JokeGraph
. The keys are the 'originating' node labels (note that
these are directed edges), and the values are the lists of
JokeGraphEdge
s themselves.
int counter
private List<Keyword> schemaInstantiations
private List<Keyword> clauseInstantiations
public static final int SCHEMA_INSTANTIATON
public static final int CLAUSE_INSTANTIATON
Constructor Detail |
---|
JokeGraph(Hashtable<String,JokeGraphNode> nodes, Hashtable<String,List<JokeGraphEdge>> edges, List<Keyword> schemaInstantiations, List<Keyword> clauseInstantiations, int nodeCounter)
nodes
- Hashtable of nodesedges
- Hashtable of edgesschemaInstantiations
- List of Keyword schema instantiationsclauseInstantiations
- List of Keyword clause instantiationsnodeCounter
- counter used to label new nodespublic JokeGraph(Schema s, Bindings b)
s
- Schema being used for this JokeGraphb
- Bindings obtained by unifying the instantiated keywords with
the schema variables.Method Detail |
---|
public JokeGraphNode getNode(String nodeID)
nodeID
-
public Iterator<JokeGraphNode> getNodes()
JokeGraph
as an
Iterator<JokeGraphNode>
.
public Iterator<JokeGraphEdge> getEdges(JokeGraphNode node)
JokeGraphNode
as an
Iterator<JokeGraphNode>
.
public List<Keyword> getSchemaInstantiations()
public List<Keyword> getClauseInstantiations()
private int getNextCount()
public JokeGraph copy()
JokeGraph
.
public void update(Clause c, Bindings b)
c
- The chosen OSF clauseb
- The bindings of the instantiationprivate void addPreconditions(Bindings bindings, List<Precondition> preconditions, SourceProcess sourceProcess, String sourceLabel)
Precondition
s, this method goes through them and
adds representations of them to this JokeGraph
. It constructs
new nodes for previously unseed lexical elements, and adds appropriate
edges.
bindings
- preconditions
- private void addVars(Bindings b, UnifiableListVar vars, SourceProcess sourceProcessCode, String sourceLabel)
b
- vars
- private void addLexNode(Bindings bindings, UnifiableVariable variable, SourceProcess sourceProcessCode, String sourceLabel)
UnifiableVariable
that is bound to a Keyword
, it
creates a new JokeGraphNodeKeyword
and replaces the binding of the
variable to the node instead.
private void addPrecondition(UnifiableCompound instantiatedPrecond, SourceProcess sp, String sl)
Precondition
.
Assumes that all argument variables have been bound to JokeGraphNodes
already1
instantiatedPrecond
- void addEdge(String edgeLabel, JokeGraphNode from, JokeGraphNode to, SourceProcess sp, String sl)
String addTemplateNode(String parentTemplateNodeID, String templateLabel, int childNumber)
public void writeXML(Writer out, String indent) throws IOException, XMLException
XMLizable
writeXML
in interface XMLizable
out
- The output stream for the XML file, which is assumed to be
already opened and writable.indent
- A string to be prepended before every line written by this
method. If passed appropriate white space, e.g.
XMLUtils.xmlIndent
, it can be used to control
indentation.
IOException
XMLException
public static JokeGraph readXML(Element e) throws XMLException
XMLException
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |