1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
package com.wcohen.ss;
/**
* Abstract distance between characters.
*
*/
abstract public class CharMatchScore
{
abstract public double matchScore(char c,char d);
/** Scores match as 0, mismatch as -1. */
static public CharMatchScore DIST_01 =
new CharMatchScore() {
public double matchScore(char c,char d) {
return Character.toLowerCase(c)==Character.toLowerCase(d) ? 0 : -1;
}
};
/** Scores match as +2, mismatch as -1. */
static public CharMatchScore DIST_21 =
new CharMatchScore() {
public double matchScore(char c,char d) {
return Character.toLowerCase(c)==Character.toLowerCase(d) ? 2 : -1;
}
};
}
|