Class TermOutputCodec

Direct Known Subclasses:
OzTermOutputCodec, PrologTermOutputCodec

public class TermOutputCodec extends MultiOutputCodec
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.
That is, the graph must be a forest, and a node has an outgoing dominance edge iff it is a hole (and exactly one dominance edge in this case). Such solved forms can be output as terms; this is what this codec does.

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 Details

    • ERROR_NOT_SIMPLE_SOLVED_FORM

      public static final int ERROR_NOT_SIMPLE_SOLVED_FORM
      See Also:
    • separator

      protected String separator
  • Constructor Details

    • TermOutputCodec

      public TermOutputCodec(String separator)
      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: OutputCodec
      Encodes a dominance graph into a string representation for this output codec. The dominance graph is defined by the arguments graph and labels. The USR is written to the writer.

      Specified by:
      encode in class OutputCodec
      Parameters:
      graph - the dominance graph
      labels - the node labels for this dominance graph
      writer - the writer to which the encoded USR will be written
      Throws:
      IOException - if an I/O error occurred while writing to the writer
      MalformedDomgraphException - if the graph cannot be encoded by this codec
    • computeTerm

      protected String computeTerm(String node, DomGraph graph, NodeLabels labels, Map<String,String> domEdges)