public class StringAlgebra extends Algebra<List<String>> implements Serializable
Notice that the algebra's signature is made aware of these nullary symbols
only when parseString(java.lang.String)
sees these symbols. This means that the contents of the signature may change
as more string representations are parsed.
Modifier and Type | Class and Description |
---|---|
static class |
StringAlgebra.Span
This class is used to represent a sub-span of an input string via its beginning
and end index.
|
Modifier and Type | Field and Description |
---|---|
static String |
CONCAT
The reserved concatenation symbol used by this algebra.
|
static String |
SPECIAL_STAR
A special symbol in the algebra that represents a terminal "*" which we
cannot represent directly, it is interpreted as [*].
|
Constructor and Description |
---|
StringAlgebra()
Creates a new instance with a new signature.
|
Modifier and Type | Method and Description |
---|---|
TreeAutomaton |
decompose(List<String> words)
Computes a decomposition automaton for the given value.
|
List<String> |
evaluate(Tree<String> t)
Evaluates a term over the algebra's signature into an algebra object.
|
String |
getBinaryConcatenation()
Returns the concatenation symbol for this algebra.
|
Class |
getClassOfValues()
Returns the class of the elements of this algebra.
|
static int |
getMaxChartSize(int sentenceLength) |
static int |
getSentenceLength(List<String> sentence) |
List<String> |
parseString(String representation)
Resolves the string representation of some element of the algebra's
domain to this element.
|
String |
representAsString(List<String> object)
Returns a string representation of this object.
|
getAllAlgebraClasses, getSignature, hasOptions, readOptions, setOptions, visualize, writeOptions
public static final String CONCAT
public static final String SPECIAL_STAR
public StringAlgebra()
public List<String> evaluate(Tree<String> t)
Algebra
public TreeAutomaton decompose(List<String> words)
Algebra
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<List<String>>
public List<String> parseString(String representation)
Algebra
TreeAlgebra.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<List<String>>
public String representAsString(List<String> object)
Algebra
Object.toString()
method. Concrete algebras may overwrite this implementation for
algebra-specific string representations. Whenever Alto knows to which
algebra an object belongs, it will attempt to call this method instead of
the generic toString to produce algebra-specific string representations.representAsString
in class Algebra<List<String>>
public static int getMaxChartSize(int sentenceLength)
public String getBinaryConcatenation()
Copyright © 2017. All rights reserved.