public class GraphAlgebra extends EvaluatingAlgebra<SGraph>
SGraph
(which see). The algebra interprets
the following operations (where G, G1, G2 are s-graphs, and a, b are source names):
merge(G1,G2)
, merges the
two graphs using SGraph.merge(de.up.ling.irtg.algebra.graph.SGraph)
.f_a(G)
forgets the
a-source of G. The resulting s-graph is like G, except that
it does not have an a-source. The operation f_a_b forgets both
a and b.r_a_b(G)
renames
the a-source of G into b, using SGraph.renameSource(java.lang.String, java.lang.String)
.
The operation r_a
is an abbreviation for
r_root_a
.s_a_b(G)
renames
the a-source of G into b and the b-source into a.merge_a_b(G1,G2)
,
first applies the rename from a to b in G2 and then merges
the result with G1.
parseString(java.lang.String)
,
i.e. they are expected to be in the extended ISI AMR format syntax.Modifier and Type | Field and Description |
---|---|
static String |
OP_COMBINEDMERGE |
static String |
OP_FORGET |
static String |
OP_MERGE |
static String |
OP_RENAME |
static String |
OP_SWAP |
Constructor and Description |
---|
GraphAlgebra()
Creates an empty graph algebra.
|
GraphAlgebra(Signature signature)
Creates a graph algebra with the given signature.
|
Modifier and Type | Method and Description |
---|---|
TreeAutomaton |
decompose(SGraph value)
Returns a bottom-up or a top-down decomposition automaton for the s-graph
value (which one can be set via setUseTopDownAutomaton ,
default is bottom-up). |
TreeAutomaton |
decompose(SGraph value,
Class c)
Given an SGraph, this returns the corresponding decomposition automaton of class c.
|
TreeAutomaton |
decomposeTopDown(SGraph value) |
SGraph |
evaluate(String label,
List<SGraph> childrenValues)
Applies the operation with name "label" to the given arguments,
and returns the result.
|
static GraphAlgebra |
makeCompleteDecompositionAlgebra(SGraph graph,
int nrSources)
Creates a GraphAlgebra based on
graph with nrSources many
sources (named 1,..,nrSources). |
static GraphAlgebra |
makeIncompleteDecompositionAlgebra(SGraph graph,
int nrSources)
Creates a GraphAlgebra based on
graph with nrSources many
sources (named 1,..,nrSources). |
SGraph |
parseString(String representation)
Parses a string into an s-graph, using
IsiAmrParser.parse(java.io.Reader) . |
void |
setUseTopDownAutomaton(boolean useTopDownAutomaton)
Sets whether this algebra uses top-down or bottom-up decomposition automata.
|
static double |
smatch(Object[] graphs,
Object[] gold)
Computes the smatch score of the two given arrays of graphs.
|
static double |
smatch(SGraph graph,
SGraph gold)
Computes the smatch score of the two given graphs.
|
boolean |
usesTopDownAutomaton()
Describes whether this algebra uses top-down or bottom-up decomposition automata.
|
JComponent |
visualize(SGraph graph)
Returns a Swing component that visualizes an object of this algebra.
|
static void |
writeIncompleteDecompositionIRTG(GraphAlgebra alg,
SGraph graph,
int nrSources,
PrintWriter writer)
Writes an IRTG grammar file based on
graph with nrSources
many sources (named 1,..,nrSources). |
boolean |
writeRestrictedAutomaton(SGraph value,
Writer writer)
Writes (nearly) all the rules in the decomposition automaton of the
SGraph value (with respect to the signature in this algebra) into the
Writer, and does not store the rules in memory.
|
static boolean |
writeRestrictedDecompositionAutomaton(SGraph value,
int sourceCount,
Writer writer)
Writes (nearly) all the rules in the decomposition automaton of the
SGraph value (with respect to the incomplete decomposition algebra)
into the Writer, and does not store the rules in memory.
|
evaluate, getSignature
getAllAlgebraClasses, getClassOfValues, hasOptions, readOptions, representAsString, setOptions, writeOptions
public static final String OP_MERGE
public static final String OP_COMBINEDMERGE
public static final String OP_RENAME
public static final String OP_SWAP
public static final String OP_FORGET
public GraphAlgebra()
public GraphAlgebra(Signature signature)
signature
- public boolean usesTopDownAutomaton()
public void setUseTopDownAutomaton(boolean useTopDownAutomaton)
useTopDownAutomaton
- public TreeAutomaton decompose(SGraph value)
value
(which one can be set via setUseTopDownAutomaton
,
default is bottom-up).decompose
in class EvaluatingAlgebra<SGraph>
value
- public TreeAutomaton decompose(SGraph value, Class c)
value
- c
- public TreeAutomaton decomposeTopDown(SGraph value)
public boolean writeRestrictedAutomaton(SGraph value, Writer writer) throws Exception
value
- writer
- Exception
public static boolean writeRestrictedDecompositionAutomaton(SGraph value, int sourceCount, Writer writer) throws Exception
value
- sourceCount
- writer
- Exception
public SGraph evaluate(String label, List<SGraph> childrenValues)
EvaluatingAlgebra
public SGraph parseString(String representation) throws ParserException
IsiAmrParser.parse(java.io.Reader)
.parseString
in class EvaluatingAlgebra<SGraph>
representation
- ParserException
public JComponent visualize(SGraph graph)
visualize
in class Algebra<SGraph>
graph
- TikzSgraphOutputCodec
public static double smatch(SGraph graph, SGraph gold) throws IOException
graph
- gold
- IOException
public static double smatch(Object[] graphs, Object[] gold) throws IOException
graphs
- gold
- IOException
public static GraphAlgebra makeCompleteDecompositionAlgebra(SGraph graph, int nrSources) throws Exception
graph
with nrSources
many
sources (named 1,..,nrSources).
The resulting algebra contains as constants all atomic subgraphs (single
edges, and single labled nodes), with all possible source combinations.
Further, the merge operation and all possible versions of forget and
rename. It is encouraged to use makeIncompleteDecompositionAlgebra
instead, since its result is equally expressive and smaller (due to
less spurious constants).graph
- nrSources
- Exception
public static GraphAlgebra makeIncompleteDecompositionAlgebra(SGraph graph, int nrSources) throws Exception
graph
with nrSources
many
sources (named 1,..,nrSources).
The resulting algebra contains as constants all atomic subgraphs (single
edges, and single labled nodes), but only one source is used for nodes,
and one more source for edges (both possibilities to name the vertices
incident to the edge with these two sources are included).
Further, the merge operation and all possible versions of forget and
rename.graph
- nrSources
- Exception
public static void writeIncompleteDecompositionIRTG(GraphAlgebra alg, SGraph graph, int nrSources, PrintWriter writer) throws Exception
graph
with nrSources
many sources (named 1,..,nrSources). The resulting irtg represents a
GraphAlgebra which contains as constants all atomic subgraphs (single
edges, and single labled nodes), but only one source is used for nodes,
and one more source for edges (both possibilities to name the vertices
incident to the edge with these two sources are included).
Further, the merge operation and all possible versions of forget and rename.
The one final state is S, the one nonfinal state is X.alg
- empty GraphAlgebra, carries the result.graph
- nrSources
- Exception
Copyright © 2017. All rights reserved.