notio.translators
Class CGIFGenerator

java.lang.Object
  |
  +--notio.translators.SimpleGenerator
        |
        +--notio.translators.CGIFGenerator
All Implemented Interfaces:
Generator

public class CGIFGenerator
extends notio.translators.SimpleGenerator
implements Generator

A CGIF Generator class.


Constructor Summary
CGIFGenerator()
           
 
Method Summary
static java.lang.String escapeCharactersInString(java.lang.String in, java.lang.String chars, char escapeSequence)
          Adds escape sequences for specified characters whenever they occur within the specified string.
 void generateActor(Actor actor)
          Generates an actor to the output stream.
 void generateCGStream(java.util.Vector graphs)
          Generates a vector of graphs to the output stream.
 void generateConcept(Concept concept)
          Generates a concept to the output stream.
 void generateGraph(Graph graph)
          Generates a graph to the output stream.
 void generateOutermostContext(Graph graph)
          Generates a graph to the output stream.
 void generateRelation(Relation relation)
          Generates a relation to the output stream.
 void generateUnit(java.lang.Object unit)
          Generates a graph to the output stream.
 boolean getAllowIncompleteRelations()
          Returns a flag indicating whether incomplete relations are allowed whilst generating.
 boolean getEmbedSingleRelatorConcepts()
          Returns a flag indicating whether this generator will embed single relator concepts within the single relation.
 boolean getIndentNestedGraphs()
          Returns a flag indicating whether this generator should generate indentation for nested graphs.
 boolean getInitiateGraphsWithNewline()
          Returns a flag indicating whether this generator should generate a newline at the beginning of every graph.
 boolean getSupressGraphComments()
          Returns a flag indicating whether this generator will supress comments in graphs.
 boolean getSupressNodeComments()
          Returns a flag indicating whether this generator will supress comments in nodes (Concepts, Relations, and Actors).
 boolean getTerminateGraphsWithNewline()
          Returns a flag indicating whether this generator should generate a newline at the end of every graph.
 java.lang.Class getUnitClass()
          Returns a Class object that indicates what class the Unit parse method will return.
 void initializeGenerator(java.io.Writer newWriter, KnowledgeBase newKnowledgeBase, TranslationContext newTranslationContext)
          Initializes the generator to write to the specified writer using the specified TranslationContext and KnowledgeBase.
 void setAllowIncompleteRelations(boolean flag)
          Sets a flag indicating whether incomplete relations are allowed whilst generating.
 void setEmbedSingleRelatorConcepts(boolean flag)
          Sets a flag indicating whether this generator should generate concepts that are not coreferent to other concepts and only related to a single relation into the relation itself.
 void setIndentNestedGraphs(boolean flag)
          Sets a flag indicating whether this generator should generate indentation before each graph, increasing the indentation for every level of nesting.
 void setInitiateGraphsWithNewline(boolean flag)
          Sets a flag indicating whether this generator should generate a newline at the beginning of every graph.
 void setSupressGraphComments(boolean flag)
          Sets a flag indicating whether this generator should supress comments in graphs.
 void setSupressNodeComments(boolean flag)
          Sets a flag indicating whether this generator should supress comments in nodes (Concepts, Relations, and Actors).
 void setTerminateGraphsWithNewline(boolean flag)
          Sets a flag indicating whether this generator should generate a newline at the end of every graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface notio.Generator
generateUnit, getUnitClass
 

Constructor Detail

CGIFGenerator

public CGIFGenerator()
Method Detail

initializeGenerator

public void initializeGenerator(java.io.Writer newWriter,
                                KnowledgeBase newKnowledgeBase,
                                TranslationContext newTranslationContext)
                         throws GeneratorException
Initializes the generator to write to the specified writer using the specified TranslationContext and KnowledgeBase.
Specified by:
initializeGenerator in interface Generator
Overrides:
initializeGenerator in class notio.translators.SimpleGenerator
Parameters:
newWriter - the writer to be generated to.
newKnowledgeBase - the knowledge base to be used while generating.
newTranslationContext - the translationContext to be used while generating.

setAllowIncompleteRelations

public void setAllowIncompleteRelations(boolean flag)
Sets a flag indicating whether incomplete relations are allowed whilst generating. If this flag is false, a GeneratorException will be thrown when an incomplete relation is encountered. If it is true, any incomplete arguments will simply be skipped as if they did not exist. If incomplete relations are allowed there is no guarantee that any CGIF parser will accept the generate output if it enforces relation valence or type definitions. The default setting for this flag is false.
Parameters:
flag - the new value for the flag.
See Also:
Relation.isComplete()

getAllowIncompleteRelations

public boolean getAllowIncompleteRelations()
Returns a flag indicating whether incomplete relations are allowed whilst generating. If this flag is false, a GeneratorException will be thrown when an incomplete relation is encountered. If it is true, any incomplete arguments will simply be skipped as if they did not exist. If incomplete relations are allowed there is no guarantee that any CGIF parser will accept the generate output if it enforces relation valence or type definitions. The default setting for this flag is false.
Returns:
the value for the flag.
See Also:
Relation.isComplete()

setSupressNodeComments

public void setSupressNodeComments(boolean flag)
Sets a flag indicating whether this generator should supress comments in nodes (Concepts, Relations, and Actors). The default setting for this flag is false.
Parameters:
flag - the new value for the flag.

getSupressNodeComments

public boolean getSupressNodeComments()
Returns a flag indicating whether this generator will supress comments in nodes (Concepts, Relations, and Actors). The default setting for this flag is false.
Returns:
the value for the flag.

setSupressGraphComments

public void setSupressGraphComments(boolean flag)
Sets a flag indicating whether this generator should supress comments in graphs. The default setting for this flag is false.
Parameters:
flag - the new value for the flag.

getSupressGraphComments

public boolean getSupressGraphComments()
Returns a flag indicating whether this generator will supress comments in graphs. The default setting for this flag is false.
Returns:
the value for the flag.

setInitiateGraphsWithNewline

public void setInitiateGraphsWithNewline(boolean flag)
Sets a flag indicating whether this generator should generate a newline at the beginning of every graph. The default setting for this flag is false.
Parameters:
flag - the new value for the flag.

getInitiateGraphsWithNewline

public boolean getInitiateGraphsWithNewline()
Returns a flag indicating whether this generator should generate a newline at the beginning of every graph. The default setting for this flag is false.
Returns:
the value for the flag.

setTerminateGraphsWithNewline

public void setTerminateGraphsWithNewline(boolean flag)
Sets a flag indicating whether this generator should generate a newline at the end of every graph. The default setting for this flag is false.
Parameters:
flag - the new value for the flag.

getTerminateGraphsWithNewline

public boolean getTerminateGraphsWithNewline()
Returns a flag indicating whether this generator should generate a newline at the end of every graph. The default setting for this flag is false.
Returns:
the value for the flag.

setIndentNestedGraphs

public void setIndentNestedGraphs(boolean flag)
Sets a flag indicating whether this generator should generate indentation before each graph, increasing the indentation for every level of nesting. Note that this will probably not look right unless the generator is set to "initiate graphs with newline". The indent will be applied after any newline, intiating or terminating. The default setting for this flag is false.
Parameters:
flag - the new value for the flag.

getIndentNestedGraphs

public boolean getIndentNestedGraphs()
Returns a flag indicating whether this generator should generate indentation for nested graphs. The default setting for this flag is false.
Returns:
the value for the flag.

setEmbedSingleRelatorConcepts

public void setEmbedSingleRelatorConcepts(boolean flag)
Sets a flag indicating whether this generator should generate concepts that are not coreferent to other concepts and only related to a single relation into the relation itself. E.g. [Dog *x] (Sleeps ?x) would be rendered as (Sleeps [Dog]). The default setting for this flag is false.
Parameters:
flag - the new value for the flag.

getEmbedSingleRelatorConcepts

public boolean getEmbedSingleRelatorConcepts()
Returns a flag indicating whether this generator will embed single relator concepts within the single relation. The default setting for this flag is false.
Returns:
the value for the flag.

generateCGStream

public void generateCGStream(java.util.Vector graphs)
                      throws GeneratorException
Generates a vector of graphs to the output stream.
Specified by:
generateCGStream in interface Generator
Parameters:
graphs - the vector of graphs to be generated.
Throws:
GeneratorException - if an error occurs while generating.

generateOutermostContext

public void generateOutermostContext(Graph graph)
                              throws GeneratorException
Generates a graph to the output stream.
Specified by:
generateOutermostContext in interface Generator
Parameters:
graph - the graph to be generated.
Throws:
GeneratorException - if an error occurs while generating.

generateGraph

public void generateGraph(Graph graph)
                   throws GeneratorException
Generates a graph to the output stream.
Specified by:
generateGraph in interface Generator
Parameters:
graph - the graph to be generated.
Throws:
GeneratorException - if an error occurs while generating.

generateConcept

public void generateConcept(Concept concept)
                     throws GeneratorException
Generates a concept to the output stream.
Specified by:
generateConcept in interface Generator
Parameters:
concept - the concept to be generated.
Throws:
GeneratorException - if an error occurs while generating.

generateRelation

public void generateRelation(Relation relation)
                      throws GeneratorException
Generates a relation to the output stream.
Specified by:
generateRelation in interface Generator
Parameters:
relation - the relation to be generated.
Throws:
GeneratorException - if an error occurs while generating.

generateActor

public void generateActor(Actor actor)
                   throws GeneratorException
Generates an actor to the output stream.
Specified by:
generateActor in interface Generator
Parameters:
relation - the relation to be generated.
Throws:
GeneratorException - if an error occurs while generating.

getUnitClass

public java.lang.Class getUnitClass()
Returns a Class object that indicates what class the Unit parse method will return.
Specified by:
getUnitClass in interface Generator
Returns:
a Class object that indicates what class the Unit parse method will return.
See Also:
Generator.generateUnit(java.lang.Object)

generateUnit

public void generateUnit(java.lang.Object unit)
                  throws GeneratorException
Generates a graph to the output stream.
Specified by:
generateUnit in interface Generator
Parameters:
unit - the unit object to be generated.
Throws:
GeneratorException - if an error occurs while generating.

escapeCharactersInString

public static java.lang.String escapeCharactersInString(java.lang.String in,
                                                        java.lang.String chars,
                                                        char escapeSequence)
Adds escape sequences for specified characters whenever they occur within the specified string.
Parameters:
in - the string to be modified.
chars - a string containing all characters that need to be escaped.
escapeSequence - the character that should prefix characters that need escaping (e.g. backslash).
Returns:
the modified string which now includes escape sequences.


Copyright 1998-2001 Finnegan Southey