Class TermOutputCodec
java.lang.Object
de.saar.chorus.domgraph.codec.OutputCodec
de.saar.chorus.domgraph.codec.MultiOutputCodec
de.saar.chorus.domgraph.codec.term.TermOutputCodec
- Direct Known Subclasses:
OzTermOutputCodec,PrologTermOutputCodec
A generic output codec for terms. This codec assumes that the
graph that is to be output is
- normal;
- leaf-labelled;
- a simple solved form.
This codec can be used to compute terms both in Oz and in Prolog syntax. The difference between these two concrete syntaxes is that Prolog inserts a comma between subterms, whereas Oz uses whitespace for the same purpose.
- Author:
- Alexander Koller
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTermOutputCodec(String separator) Construct a new term output codec with the given subterm separator (e.g. "," for Prolog, " " for Oz). -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcomputeTerm(String node, DomGraph graph, NodeLabels labels, Map<String, String> domEdges) voidencode(DomGraph graph, NodeLabels labels, Writer writer) Encodes a dominance graph into a string representation for this output codec.voidprint_end_list(Writer writer) Prints the end of a list in the concrete syntax which the USR uses.voidprint_footer(Writer writer) Prints a footer at the end of a file to which the USR is written.voidprint_header(Writer writer) Prints a header at the beginning of a file to which the USR is written.voidprint_list_separator(Writer writer) Prints the separator for separating different items of a list in the concrete syntax which the USR uses.voidprint_start_list(Writer writer) Prints the beginning of a list in the concrete syntax which the USR uses.
-
Field Details
-
ERROR_NOT_SIMPLE_SOLVED_FORM
public static final int ERROR_NOT_SIMPLE_SOLVED_FORM- See Also:
-
separator
-
-
Constructor Details
-
TermOutputCodec
Construct a new term output codec with the given subterm separator (e.g. "," for Prolog, " " for Oz).- Parameters:
separator- the subterm separator
-
-
Method Details
-
encode
public void encode(DomGraph graph, NodeLabels labels, Writer writer) throws IOException, MalformedDomgraphException Description copied from class:OutputCodecEncodes a dominance graph into a string representation for this output codec. The dominance graph is defined by the argumentsgraphandlabels. The USR is written to thewriter.- Specified by:
encodein classOutputCodec- Parameters:
graph- the dominance graphlabels- the node labels for this dominance graphwriter- the writer to which the encoded USR will be written- Throws:
IOException- if an I/O error occurred while writing to thewriterMalformedDomgraphException- if the graph cannot be encoded by this codec
-
computeTerm
-
print_header
Description copied from class:OutputCodecPrints a header at the beginning of a file to which the USR is written.- Specified by:
print_headerin classOutputCodec- Parameters:
writer- the writer
-
print_start_list
Description copied from class:MultiOutputCodecPrints the beginning of a list in the concrete syntax which the USR uses. This method is called afterprint_header, but before any of the USRs. It is only called if we print more than one graph (e.g. in the solve command, but not the convert command).- Specified by:
print_start_listin classMultiOutputCodec- Parameters:
writer- the writer- Throws:
IOException- if an I/O error occurred
-
print_end_list
Description copied from class:MultiOutputCodecPrints the end of a list in the concrete syntax which the USR uses. This method is called beforeprint_footer, but after any of the USRs. It is only called if we print more than one graph (e.g. in the solve command, but not the convert command).- Specified by:
print_end_listin classMultiOutputCodec- Parameters:
writer- the writer- Throws:
IOException- if an I/O error occurred
-
print_list_separator
Description copied from class:MultiOutputCodecPrints the separator for separating different items of a list in the concrete syntax which the USR uses.- Specified by:
print_list_separatorin classMultiOutputCodec- Parameters:
writer- the writer- Throws:
IOException- if an I/O error occurred
-