public class BolinasHrgInputCodec extends InputCodec<InterpretedTreeAutomaton>
GraphAlgebra
.Because the graph algebra only represents graphs (and not hypergraphs), the conversion will only be successful if every ordinary hyperedge in the rules (i.e., every hyperedge that is not labeled with a nonterminal) has one or two endpoints. These hyperedges are translated as follows:
setConvertUnaryEdgesToNodeLabels(boolean)
to
switch to a behavior where hyperedges with a single endpoint are translated
into loops, i.e. into edges from the source node to itself with the given
edge label.Whether you want the loop encoding of unary edges or the node label encoding depends on how you represent node labels in the graphs you're trying to parse. The unmodified AMR-Bank uses node labels, which is why the node-label encoding is the default behvior of the codec.
Nonterminal hyperedges are treated differently, and may still have an arbitrary number of endpoints.
The codec allows you to specify external nodes of the graph on the right-hand side of a rule either with an anonymous marker (".*") or with an explicit marker ("*.2"). The Bolinas documentation does not specify precisely how anonymous and explicit markers can be mixed, so we recommend against mixing both kinds in the same rule. Anonymous markers are translated into external nodes in ascending order, from left to right in the rule. Explicit markers are translated into external nodes in ascending order; note that it is okay to use e.g. *.1 and *.3 but not *.2. The root of the RHS graph is always translated into the first external node.
A note of caution: This class is not thread-safe. If you want to use it in a multi-threaded environment, you should make a separate codec object for each thread.
Constructor and Description |
---|
BolinasHrgInputCodec() |
Modifier and Type | Method and Description |
---|---|
boolean |
isConvertUnaryEdgesToNodeLabels()
Returns the current behavior with respect to encoding non-nonterminal
unary hyperedges.
|
InterpretedTreeAutomaton |
read(InputStream is)
Reads an object from an input stream.
|
void |
setConvertUnaryEdgesToNodeLabels(boolean convertUnaryEdgesToNodeLabels)
Select how the codec should encode non-nonterminal hyperedges with single
endpoints.
|
addOptions, getAllInputCodecs, getInputCodecByExtension, getInputCodecByName, getInputCodecByNameOrExtension, getInputCodecs, getMetadata, getOption, hasTrueOption, main, read, setOption, setProgressListener
public boolean isConvertUnaryEdgesToNodeLabels()
setConvertUnaryEdgesToNodeLabels(boolean)
public void setConvertUnaryEdgesToNodeLabels(boolean convertUnaryEdgesToNodeLabels)
convertUnaryEdgesToNodeLabels
- public InterpretedTreeAutomaton read(InputStream is) throws CodecParseException, IOException
InputCodec
read
in class InputCodec<InterpretedTreeAutomaton>
CodecParseException
- if an error occurred while decoding
the input stream into an objectIOException
- if an error occurred while reading
data from the input streamCopyright © 2017. All rights reserved.