File: CharMatchScore.java

package info (click to toggle)
libsecondstring-java 0.1~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 764 kB
  • sloc: java: 9,592; xml: 114; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 639 bytes parent folder | download
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;
		}
	};
	
}