public class TreeAlgebra extends Algebra<Tree<String>>
Constructor and Description |
---|
TreeAlgebra() |
Modifier and Type | Method and Description |
---|---|
static int |
countBrackets(Tree<String> tree)
Counts the number of nodes in a tree - minus the number of the leaf nodes.
|
TreeAutomaton |
decompose(Tree<String> value)
Computes a decomposition automaton for the given value.
|
Tree<String> |
evaluate(Tree<String> t)
Evaluates a term over the algebra's signature into an algebra object.
|
Class |
getClassOfValues()
Returns the class of the elements of this algebra.
|
Tree<String> |
parseString(String representation)
Resolves the string representation of some element of the algebra's
domain to this element.
|
static double |
precision(Tree<String> result,
Tree<String> gold)
Computes the standard precision measure for two trees.
|
static double |
recall(Tree<String> result,
Tree<String> gold)
Computes the standard recall measure for two trees.
|
JComponent |
visualize(Tree<String> object)
Returns a Swing component that visualizes an object of this algebra.
|
getAllAlgebraClasses, getSignature, hasOptions, readOptions, representAsString, setOptions, writeOptions
public Tree<String> evaluate(Tree<String> t)
Algebra
public TreeAutomaton decompose(Tree<String> value)
Algebra
public JComponent visualize(Tree<String> object)
Algebra
public Tree<String> parseString(String representation) throws ParserException
Algebra
parseString(java.lang.String)
resolves the string "f(a,b)" into a tree with three nodes.It is the job of an algebra class to keep track of the signature of the algebra. Many algebras have a potentially infinite domain (e.g. the string algebra can be used with arbitrary alphabets), so the algebra class should keep track of the symbols that were actually used in the current run of the program. The best practice is to update the signature each time the parseString method is called. The rest of the IRTG tool code takes care to call parseString of the respective algebra to obtain objects of type E, so this ensures that the signature is always up-to-date.
parseString
in class Algebra<Tree<String>>
ParserException
public Class getClassOfValues()
Algebra
Object
; you may override this with
the actual class of the objects of your algebra.
This method is used in some places throughout Alto to figure out what
OutputCodec
s are appropriate for encoding objects of the algebra.
By overriding the method to return more specific classes than Object, you
make more output codecs available in those places.
getClassOfValues
in class Algebra<Tree<String>>
public static int countBrackets(Tree<String> tree)
tree
- public static double recall(Tree<String> result, Tree<String> gold)
result
- gold
- Copyright © 2017. All rights reserved.