standup.joke
Class JokeStructure

java.lang.Object
  extended by standup.joke.JokeStructure
All Implemented Interfaces:
Comparable, XMLizable

public class JokeStructure
extends Object
implements XMLizable, Comparable

A generated joke, with all its underlying data structures. These objects are either created by Generator, read in from an XML file using XMLReaders, or handcrafted using .

TODO Still need to sort out which textual data structures will be supported: JokeTexts, JokeForms, etc.

Author:
Ruli Manurung

Field Summary
(package private)  String answerTemplate
           
(package private)  WordStruct answerWordStruct
           
(package private)  float cachedMinFScoreA
           
(package private)  float cachedMinFScoreQ
           
private  String id
           
(package private)  JokeGraph jokeGraph
           
(package private)  double phoneticSimilarityThreshold
          This field records the lowest phonetic similarity score used in this JokeStructure, or 1.0 if no homophone relations are used.
(package private)  String questionTemplate
           
(package private)  WordStruct questionWordStruct
           
(package private)  String schemaLabel
           
 
Constructor Summary
JokeStructure(String _id, String s, String tq, String ta, WordStruct wq, WordStruct wa, JokeGraph jg, double pst)
           
 
Method Summary
 boolean about(Topic t)
           
 int compareTo(Object arg0)
          TODO This definition of compareTo is NOT CONSISTENT WRT EQUALS!
 boolean equals(Object obj)
          TODO Two JokeStructures are considered equals if they have the same: - schema label, - question template label, - answer template label, - schema instantiations, - clause instantiations.
 String getAnswer()
           
 WordStruct getAnswerStruct()
           
 JokeGraph getGraph()
           
 String getID()
           
 int getMaximumAmbiguity()
           
 float getMinimumAnswerFScore()
           
 float getMinimumQuestionFScore()
           
 double getPhoneticSimilarityThreshold()
           
 String getQuestion()
           
 WordStruct getQuestionStruct()
           
 String getSchemaLabel()
           
 int hashCode()
           
 boolean ofType(JokeType t)
           
 boolean ofType(List<SchemaTemplatePair> stps)
          An alternative ofType() method which checks against an arbitrary List, e.g.
static JokeStructure readXML(Element e)
           
 boolean satisfies(JokeConstraints constraints)
           
 void setID(String newID)
           
 String toString()
           
 String toVerboseString()
           
 boolean uses(Lexeme l)
           
 boolean usesAll(LexemeSet ls)
           
 boolean usesAllInAnswer(LexemeSet ls)
           
 boolean usesAllInQuestion(LexemeSet ls)
           
 boolean usesAny(LexemeSet ls)
           
 boolean usesAnyInAnswer(LexemeSet ls)
           
 boolean usesAnyInQuestion(LexemeSet ls)
           
 boolean usesInAnswer(Lexeme l)
           
 boolean usesInQuestion(Lexeme l)
           
 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

id

private String id

schemaLabel

final String schemaLabel

questionTemplate

final String questionTemplate

answerTemplate

final String answerTemplate

phoneticSimilarityThreshold

final double phoneticSimilarityThreshold
This field records the lowest phonetic similarity score used in this JokeStructure, or 1.0 if no homophone relations are used.


questionWordStruct

WordStruct questionWordStruct

answerWordStruct

WordStruct answerWordStruct

jokeGraph

JokeGraph jokeGraph

cachedMinFScoreQ

float cachedMinFScoreQ

cachedMinFScoreA

float cachedMinFScoreA
Constructor Detail

JokeStructure

public JokeStructure(String _id,
                     String s,
                     String tq,
                     String ta,
                     WordStruct wq,
                     WordStruct wa,
                     JokeGraph jg,
                     double pst)
Method Detail

getID

public String getID()

setID

public void setID(String newID)

getSchemaLabel

public String getSchemaLabel()

getQuestionStruct

public WordStruct getQuestionStruct()

getAnswerStruct

public WordStruct getAnswerStruct()

compareTo

public int compareTo(Object arg0)
TODO This definition of compareTo is NOT CONSISTENT WRT EQUALS!

Specified by:
compareTo in interface Comparable
Parameters:
arg0 -
Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
TODO Two JokeStructures are considered equals if they have the same: - schema label, - question template label, - answer template label, - schema instantiations, - clause instantiations. Note that this may equate 2 JokeStructures that have slight surface generation differences (i.e. different phrasal templates)

Overrides:
equals in class Object

getQuestion

public String getQuestion()

getAnswer

public String getAnswer()

toString

public String toString()
Overrides:
toString in class Object

toVerboseString

public String toVerboseString()

ofType

public boolean ofType(JokeType t)

ofType

public boolean ofType(List<SchemaTemplatePair> stps)
An alternative ofType() method which checks against an arbitrary List, e.g. one built up by a JokeConstraintTypes

Parameters:
stps -
Returns:

satisfies

public boolean satisfies(JokeConstraints constraints)

uses

public boolean uses(Lexeme l)

usesInQuestion

public boolean usesInQuestion(Lexeme l)

usesInAnswer

public boolean usesInAnswer(Lexeme l)

usesAny

public boolean usesAny(LexemeSet ls)

usesAnyInQuestion

public boolean usesAnyInQuestion(LexemeSet ls)

usesAnyInAnswer

public boolean usesAnyInAnswer(LexemeSet ls)

usesAll

public boolean usesAll(LexemeSet ls)

usesAllInQuestion

public boolean usesAllInQuestion(LexemeSet ls)

usesAllInAnswer

public boolean usesAllInAnswer(LexemeSet ls)

about

public boolean about(Topic t)

getPhoneticSimilarityThreshold

public double getPhoneticSimilarityThreshold()

getMaximumAmbiguity

public int getMaximumAmbiguity()

getMinimumQuestionFScore

public float getMinimumQuestionFScore()

getMinimumAnswerFScore

public float getMinimumAnswerFScore()

writeXML

public void writeXML(Writer out,
                     String indent)
              throws IOException,
                     XMLException
Description copied from interface: XMLizable
This method writes the necessary information contained within an instance to an XML file.

Specified by:
writeXML in interface XMLizable
Parameters:
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.
Throws:
IOException
XMLException

readXML

public static JokeStructure readXML(Element e)
                             throws XMLException
Throws:
XMLException

getGraph

public JokeGraph getGraph()