X
- the class of the elements in the left input sequence.Y
- the class of the elements in the right input sequence.R
- the result class of this algorithm.N
- the enum containing the nonterminal symbols of the input grammar.public abstract class AbstractADPAlgorithm<X,Y,R,N extends Enum<N>> extends Object implements AlignmentAlgorithm<X,Y,R>
Constructor and Description |
---|
AbstractADPAlgorithm(Grammar<N> grammar,
Class<R> resultClass,
Comparator<X,Y> comparator) |
Modifier and Type | Method and Description |
---|---|
R |
calculateAlignment(List<X> a,
List<Y> b)
This calculates the alignment dissimilarity D between the Sequences x ∈ X* and y ∈
Y* and returns it as an instance of the result class for this algorithm.
|
abstract double |
choice(double[] choices)
This should implement the choice function as the term is used
in the Bellman's Gap context.
|
Comparator<X,Y> |
getComparator()
This should return the Comparator used to compute local distances for this algorithm.
|
Class<R> |
getResultClass()
This method shall return the class of the alignment result.
|
static <X,Y> double |
normalizeDissimilarity(double d,
List<X> a,
List<Y> b)
Normalizes the given raw distance by the worst case that could occur in an alignment of the
two sequences: In the worst case, we replace all elements in a with elements in b and
delete/insert the remaining elements in the longer sequence.
|
boolean |
requires(OperationType type)
This method should return true if and only if this AlignmentAlgorithm uses the given
operation.
|
void |
setComparator(Comparator<X,Y> comparator)
This should set the Comparator used to compute local distances for this algorithm.
|
abstract R |
transformToResult(EnumMap<N,double[][]> dpTables,
EnumMap<OperationType,double[][]> repMatrices,
EnumMap<OperationType,double[]> delVectors,
EnumMap<OperationType,double[]> insVectors,
List<X> a,
List<Y> b)
This method should not be called from outside!
|
public Class<R> getResultClass()
AlignmentAlgorithm
getResultClass
in interface AlignmentAlgorithm<X,Y,R>
public void setComparator(@NonNull Comparator<X,Y> comparator)
AlignmentAlgorithm
setComparator
in interface AlignmentAlgorithm<X,Y,R>
comparator
- the comparator that is used to compute local distances for this Algorithm.public Comparator<X,Y> getComparator()
AlignmentAlgorithm
getComparator
in interface AlignmentAlgorithm<X,Y,R>
public R calculateAlignment(@NonNull List<X> a, @NonNull List<Y> b)
AlignmentAlgorithm
calculateAlignment
in interface AlignmentAlgorithm<X,Y,R>
a
- The left input sequence.b
- The right input sequence.public boolean requires(@NonNull OperationType type)
AlignmentAlgorithm
requires
in interface AlignmentAlgorithm<X,Y,R>
type
- an OperationType.public static <X,Y> double normalizeDissimilarity(double d, @NonNull List<X> a, @NonNull List<Y> b)
X
- the class of elements in the first input sequence.Y
- the class of elements in the second input sequence.d
- the raw alignment distance between sequences a and b in the range [0,infinity)a
- the left-hand input sequence.b
- the right-hand input sequence.public abstract double choice(@NonNull double[] choices)
choices
- the costs of all choices.public abstract R transformToResult(@NonNull EnumMap<N,double[][]> dpTables, @NonNull EnumMap<OperationType,double[][]> repMatrices, @NonNull EnumMap<OperationType,double[]> delVectors, @NonNull EnumMap<OperationType,double[]> insVectors, @NonNull List<X> a, @NonNull List<Y> b)
dpTables
- the dynamic programming matrices used during
calculation.repMatrices
- the local cost for replacing node i from the first
sequence with node j from the second sequence.delVectors
- the local cost for deleting node i from the first
sequence.insVectors
- the local cost for inserting node j from the
second sequence into the first sequence.a
- the first sequence.b
- th second sequence.Copyright (C) 2016-2018 Benjamin Paaßen, AG Theoretical Computer Science, Centre of Excellence Cognitive Interaction Technology (CITEC), University of Bielefeld, licensed under the AGPL v. 3: http://openresearch.cit-ec.de/projects/tcs . This documentation is licensed under the conditions of CC-BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/