public class AlignmentSpecification extends IndexingScheme implements DerivableComparator<Node,Node>
Constructor and Description |
---|
AlignmentSpecification(AlignmentSpecification other)
Constructs a copy of the given other AlignmentSpecification.
|
AlignmentSpecification(NodeSpecification nodeSpecification,
String[] keywords,
ValueComparator[] comparators) |
AlignmentSpecification(NodeSpecification nodeSpecification,
String[] keywords,
ValueComparator[] comparators,
double[] weighting) |
AlignmentSpecification(NodeSpecification nodeSpecification,
ValueComparator[] comparators) |
Modifier and Type | Method and Description |
---|---|
double[] |
calculateComparatorDistances(OperationType type,
Node a,
Node b)
Calculates the distances returned by every single Comparator in this AlignmentSpecification.
|
double |
compare(OperationType type,
Node a,
Node b)
This method returns a dissimilarity between x and y using the alignment operation op with the
following restrictions:
compare(op,x,y) ≥ 0 (non-negativity)
compare(op,x,y) ≤ 1 (normalization)
x = y ⇒ compare(op,x,y) = 0 (equality)
Further, this function guarantees consistency with respect to null inputs, that is, for any
operation op ∈ {REPLACEMENT, DELETIONREPLACEMENT, INSERTIONREPLACEMENT} it holds:
d(op, x, null) = d(DELETION, x, null)
d(op, null, y) = d(INSERTION, null, y)
and for any operation it holds:
d(op, null, null) = 0
Please note that a and b might be null if this alignment uses gaps or
skips.
|
Gradient |
computeGradient(OperationType type,
Node a,
Node b)
Computes the gradient of this comparator function w.r.t.
|
boolean |
equals(Object obj) |
ValueComparator |
getComparator(int index)
Returns the Comparator that is currently set for the given keyword.
|
ValueComparator |
getComparator(String keyword)
Returns the Comparator that is currently set for the given keyword.
|
NodeSpecification |
getNodeSpecification() |
int |
getNumberOfParameters()
This shall return the number of parameters of this comparator.
|
int |
getOriginalIndex(int index)
This is semantically equivalent to
getNodeSpecification().getKeywordIndex(getKeyword(index)) but this is
preprocessed here for better performance.
|
double[] |
getParameters()
Return the current value of all parameters of this comparator.
|
double[] |
getWeighting()
Returns the current keyword weighting.
|
boolean |
hasCoherentReplacementCost()
This method should return true if and only if this Comparator guarantees that
compare(OperationType.REPLACEMENT, x, y) =
compare(OperationType.DELETIONREPLACEMENT, x, y) =
compare(OperationType.INSERTIONREPLACEMENT, x, y)
for all possible inputs x, y.
|
int |
hashCode() |
static boolean |
isValidWeighting(double[] weighting)
This checks whether the given weighting is a valid one.
|
void |
setComparator(int index,
ValueComparator comparator)
Sets the comparator for a given keyword.
|
void |
setComparator(String keyword,
ValueComparator comparator)
Sets the comparator for a given keyword.
|
void |
setParameters(double[] params)
Sets the current value of all parameters of this comparator.
|
void |
setWeighting(double[] weighting)
This sets the current weighting of keywords.
|
boolean |
supports(OperationType type)
This method should return true if and only if this Comparator supports the given alignment
operation.
|
String |
toString() |
getKeyword, getKeywordIndex, getKeywords, hasKeyword, size
public AlignmentSpecification(@NonNull AlignmentSpecification other)
other
- another AlignmentSpecification that shall be copied.public AlignmentSpecification(@NonNull NodeSpecification nodeSpecification, @NonNull ValueComparator[] comparators)
nodeSpecification
- The node specification that is the basis of all
sequences for this alignment.comparators
- the comparators that shall be used for the keywords.
Please note that these have to match the types of the keywords.public AlignmentSpecification(@NonNull NodeSpecification nodeSpecification, @NonNull String[] keywords, @NonNull ValueComparator[] comparators)
nodeSpecification
- The node specification that is the basis of all
sequences for this alignment.keywords
- The keywords that shall be used in this alignment. This
has to be a subset of the keywords in the node specification.comparators
- the comparators that shall be used for the keywords.
Please note that these have to match the types of the keywords.public AlignmentSpecification(@NonNull NodeSpecification nodeSpecification, @NonNull String[] keywords, @NonNull ValueComparator[] comparators, @NonNull double[] weighting)
nodeSpecification
- The node specification that is the basis of all
sequences for this alignment.keywords
- The keywords that shall be used in this alignment. This
has to be a subset of the keywords in the node specification.comparators
- the comparators that shall be used for the keywords.
Please note that these have to match the types of the keywords.weighting
- the weights that highlight the importance of certain
keywords/features. These have to be double values between 0 and 1 that
add up to 1.public NodeSpecification getNodeSpecification()
public void setComparator(@NonNull String keyword, @NonNull ValueComparator comparator)
keyword
- a keyword that is used in this Alignment.comparator
- a fitting Comparator that defines a local normalized
distance on the values for the given keyword.public void setComparator(int index, @NonNull ValueComparator comparator)
index
- a keyword index that is used in this Alignment.comparator
- a fitting Comparator that defines a local normalized
distance on the values for the given keyword.public ValueComparator getComparator(@NonNull String keyword)
keyword
- a keyword that is used in this Alignment.public ValueComparator getComparator(int index)
index
- a keyword index that is used in this Alignment.public int getOriginalIndex(int index)
index
- a keyword index in this AlignmentSpecification.public void setWeighting(@NonNull double[] weighting)
weighting
- a double vector fulfilling the criteria given above.public double[] getWeighting()
public int getNumberOfParameters()
DerivableComparator
getNumberOfParameters
in interface DerivableComparator<Node,Node>
public double[] getParameters()
DerivableComparator
getParameters
in interface DerivableComparator<Node,Node>
public void setParameters(double[] params)
DerivableComparator
setParameters
in interface DerivableComparator<Node,Node>
params
- the new value of all parameters of this comparator.public double compare(@NonNull OperationType type, Node a, Node b)
Comparator
compare
in interface Comparator<Node,Node>
type
- the type of alignment operation to be used.a
- the left input.b
- the right input.public boolean supports(OperationType type)
Comparator
supports
in interface Comparator<Node,Node>
type
- an alignment OperationType.public boolean hasCoherentReplacementCost()
Comparator
hasCoherentReplacementCost
in interface Comparator<Node,Node>
public Gradient computeGradient(@NonNull OperationType type, Node a, Node b)
DerivableComparator
computeGradient
in interface DerivableComparator<Node,Node>
type
- the type of alignment operation to be useda
- the left input.b
- the right input.public double[] calculateComparatorDistances(@NonNull OperationType type, Node a, Node b)
type
- the OperationType of the the alignment operation that shall be applied.a
- the left-hand node for the comparison.b
- the right-hand node for the comparison.public static boolean isValidWeighting(@NonNull double[] weighting)
weighting
- a double array that might be a weighting.public int hashCode()
hashCode
in class IndexingScheme
public boolean equals(Object obj)
equals
in class IndexingScheme
Copyright (C) 2016 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/