public class CGIFWriter
extends Object
Modifier and Type | Field and Description |
---|---|
private String |
indent
This string represents the indention applied to inner subcontexts
|
private NameGenerator |
nameGenerator
Used to generate unique label names for concepts in the graph that do not
contain constants.
|
private HashMap<GraphObjectID,String> |
nameTable
Table mapping GraphObject objectID's to defining/bound label names
|
private PrintStream |
stream
Output stream to which to write the conceptual graphs
|
private boolean |
writeComments
Flag specifying if comments should be written when generating CGIF
|
Constructor and Description |
---|
CGIFWriter(OutputStream out)
Creates a CGIFWriter that can write conceptual graphs in CGIF format to
the specified output stream using a default sub-context indention of four
whitespaces.
|
CGIFWriter(OutputStream out,
String indent)
Creates a CGIFWriter that can write conceptual graphs in CGIF format to
the specified output stream using the specified sub-context indention.
|
CGIFWriter(OutputStream out,
String indent,
boolean writeComments)
Creates a CGIFWriter that can write conceptual graphs in CGIF format to
the specified output stream using the specified sub-context indention.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCorefLinks(Concept concept,
String corefName)
Adds coreference name entries for the specified concept and all the
linked concept to the corefNameTable.
|
protected String |
generateComment(GraphObject go)
Returns a string representation of the comment for the specified object.
|
String |
getIndention()
Returns the string representing the indention applied to the beginning of
each new subcontext.
|
static String |
graphToString(Graph graph)
Converts the specified graph into a string representation of the standard
CGIF format without comments.
|
static String |
graphToString(Graph graph,
boolean writeComments)
Converts the specified graph into a string representation of the standard
CGIF format.
|
protected static boolean |
needsQuote(String s)
Examines a string and if it contains all "normal" characters, don't quote it.
|
protected static String |
quotify(String s)
Delimit a string with double quotes, and escape (via substituting
\u0022 for double quote) any double quotes in the string. |
protected static String |
quotifyWithPrefix(String s) |
void |
setIndention(String indent)
Sets the string to be applied to the beginning of each new subcontext.
|
protected void |
sortInputEdges(List<GEdge> edges)
This sorts the specified input edges.
|
void |
write(Graph graph)
Writes the specified graph to the output stream of this class using the
standard CGIF format.
|
protected void |
write(Graph graph,
String currIndent)
Writes the specified graph to the output stream of this class using the
standard CGIF format.
|
static void |
write(OutputStream out,
Graph graph)
Writes the specified graph to the specified output stream using the
standard CGIF format without comments.
|
static void |
write(OutputStream out,
Graph graph,
boolean writeComments)
Writes the specified graph to the specified output stream using the
standard CGIF format.
|
protected void |
writeConcepts(List<Concept> concepts,
String currIndent)
Writes the specified concepts to the output stream of this class using
the standard CGIF format.
|
protected void |
writeGenSpecLinks(List<GenSpecLink> genspeclinks,
String currIndent)
Write the generalization-specialization links, with all the types on one line
and all the subtype relations on a second line, in accordance with Dr.
|
protected <T> void |
writeLinkingNodes(List<? extends GNode> nodes,
String currIndent)
Writes the specified nodes that link concepts (Actor or Relation) to the
output stream of this class using the standard CGIF format.
|
static void |
writeToFile(String filename,
Graph graph)
Writes the specified graph to a file with the specified filename using
the standard CGIF format without comments.
|
static void |
writeToFile(String filename,
Graph graph,
boolean writeComments)
Writes the specified graph to a file with the specified filename using
the standard CGIF format.
|
private NameGenerator nameGenerator
private HashMap<GraphObjectID,String> nameTable
private PrintStream stream
private String indent
private boolean writeComments
public CGIFWriter(OutputStream out)
out
- Output stream to which to write the conceptual graphspublic CGIFWriter(OutputStream out, String indent)
out
- Output stream to which to write the conceptual graphsindent
- Indention applied to each sub-contextpublic CGIFWriter(OutputStream out, String indent, boolean writeComments)
out
- Output stream to which to write the conceptual graphsindent
- Indention applied to each sub-contextwriteComments
- Flag specifying if comments should be writtenpublic static void write(OutputStream out, Graph graph)
out
- Output stream to which to write the graphgraph
- Graph to convert and write outpublic static void write(OutputStream out, Graph graph, boolean writeComments)
out
- Output stream to which to write the graphgraph
- Graph to convert and write outwriteComments
- Flag specifying if comments should be writtenpublic static void writeToFile(String filename, Graph graph) throws FileNotFoundException, IOException
filename
- Name of the file to which to write the graphgraph
- Graph to convert and write outFileNotFoundException,
- IOExceptionFileNotFoundException
IOException
public static void writeToFile(String filename, Graph graph, boolean writeComments) throws FileNotFoundException, IOException
filename
- Name of the file to which to write the graphgraph
- Graph to convert and write outwriteComments
- Flag specifying if comments should be writtenFileNotFoundException,
- IOExceptionFileNotFoundException
IOException
public static String graphToString(Graph graph)
graph
- Graph to convert to a stringpublic static String graphToString(Graph graph, boolean writeComments)
graph
- Graph to convert to a stringwriteComments
- Flag specifying if comments should be writtenpublic String getIndention()
public void setIndention(String indent)
indent
- Indention string to be applied to each subcontextpublic void write(Graph graph)
graph
- Graph to convert and write outprotected void write(Graph graph, String currIndent)
graph
- Graph to convert and write outcurrIndent
- Indention for each line for the current contextprotected void writeGenSpecLinks(List<GenSpecLink> genspeclinks, String currIndent)
genspeclinks
- currIndent
- protected void writeConcepts(List<Concept> concepts, String currIndent)
concepts
- List of concepts to printcurrIndent
- Indention for each line for the current contextprotected <T> void writeLinkingNodes(List<? extends GNode> nodes, String currIndent)
nodes
- List of Actors or RelationscurrIndent
- Indention for each line for the current contextprotected void addCorefLinks(Concept concept, String corefName)
concept
- Concept to addcorefName
- Name of the coreference link without any special CGIF
charactersprotected void sortInputEdges(List<GEdge> edges)
edges
- Edges to be sortedprotected String generateComment(GraphObject go)
go
- GraphObject of which to generate a commentprotected static String quotify(String s)
\u0022
for double quote) any double quotes in the string.
See https://www.fileformat.info/info/unicode/char/0022/index.htm
for a description of this character.s
- \u0022
. All other characters are preserved.protected static String quotifyWithPrefix(String s)
protected static boolean needsQuote(String s)
s
-