public class DemerauLevenshtein extends FunctionMetric
evaluate(String compOne, String compTwo)
method. As the classes
have been made generic, it is also possible to attempt a Demerau-Levenshtein evaluation over
other data types. For this, you might be required to add the evaluation function that
evaluates the data comparison. You would then use the evaluate(Object parameter)
method to attempt the comparison. The desired result is a smaller distance, but you can
use the isBetter()
method to determine what value is better. The count result
is inherently an Integer, so cast a reply to that.
This is a modified version of, but using the same algorithm: http://blogs.ucl.ac.uk/chime/2010/06/28/java-example-code-of-common-similarity-algorithms-used-in-data-mining/
config, mathCompare, valueType
Constructor and Description |
---|
DemerauLevenshtein()
Create a new instance of DemerauLevenshtein.
|
DemerauLevenshtein(java.lang.String thisValueType)
Create a new instance of DemerauLevenshtein.
|
Modifier and Type | Method and Description |
---|---|
ReplySet |
evaluate(MetricDataset ds1,
MetricDataset ds2)
Evaluate the comparison between the two data lists and return the result.
|
ReplySet |
evaluate(java.lang.Object dataset)
Return a value based on the function evaluation.
|
int |
evaluate(java.lang.String compOne,
java.lang.String compTwo)
Return a value based on the function evaluation.
|
int[][] |
getMatrix(java.lang.String compOne,
java.lang.String compTwo)
Create and return the matrix.
|
protected void |
initialise()
Initialise the function values, setting the config parameters or other.
|
boolean |
isBetter(java.lang.String valueType,
java.lang.Object value1,
java.lang.Object value2)
Return true if value2 is better than value1, as determined by the measurements of
this evaluation function.
|
FunctionMetric |
newInstance()
Create and return a new instance of the function, initialised with this function's
value type
valueType and math evaluator mathCompare . |
void |
printMatrix(java.lang.String compOne,
java.lang.String compTwo)
For testing, to print the matrix to stdout.
|
boolean |
sib()
Return true if a smaller distance between the two vectors is better.
|
evaluateCompare, lib
checkValueType, createFunction, createFunction, createFunction, evaluate, getConfigParams, innerObject, isLegalNumber, setConfigParams, setEvaluator, setValueType
public DemerauLevenshtein() throws java.lang.Exception
java.lang.Exception
- any error.public DemerauLevenshtein(java.lang.String thisValueType) throws java.lang.Exception
thisValueType
- the type of object being evaluated.java.lang.Exception
- any error.protected void initialise() throws java.lang.Exception
initialise
in class Function
java.lang.Exception
- any error.public ReplySet evaluate(java.lang.Object dataset) throws java.lang.Exception
dataset
- the value to pass through the function. This can be either
a String[2]
or a MetricCompare
with only one data object, in each
of the data lists.java.lang.Exception
- any error.public ReplySet evaluate(MetricDataset ds1, MetricDataset ds2) throws java.lang.Exception
evaluate
in interface FunctionMetricDef
evaluate
in class FunctionMetric
ds1
- the first set of data values.ds2
- the second set of data values.java.lang.Exception
- any error.public int evaluate(java.lang.String compOne, java.lang.String compTwo) throws java.lang.Exception
compOne
- the first comparison string.compTwo
- the second comparison string.java.lang.Exception
- any error.public int[][] getMatrix(java.lang.String compOne, java.lang.String compTwo)
compOne
- the first comparison string.compTwo
- the second comparison string.public void printMatrix(java.lang.String compOne, java.lang.String compTwo)
compOne
- the first comparison string.compTwo
- the second comparison string.public boolean isBetter(java.lang.String valueType, java.lang.Object value1, java.lang.Object value2) throws java.lang.Exception
isBetter
in class FunctionMetric
valueType
- the java type of the values to be evaluated.value1
- the first value type.value2
- the second value type.java.lang.Exception
- any error.public boolean sib()
sib
in class FunctionMetric
public FunctionMetric newInstance() throws java.lang.Exception
valueType
and math evaluator mathCompare
.newInstance
in class FunctionMetric
java.lang.Exception
- any error.