File: ScaledLevenstein.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 (24 lines) | stat: -rwxr-xr-x 580 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
package com.wcohen.ss;

import com.wcohen.ss.api.*;

/**
 * Levenstein string distance. Levenstein distance is basically
 * NeedlemanWunsch with unit costs for all operations.
 */

public class ScaledLevenstein extends Levenstein
{
	
	public double score(StringWrapper s,StringWrapper t){
		double d = super.score(s,t);
		double n = Math.max((double)s.length(),(double)t.length());
		return (1 + (d/n));
	}
	
	public String toString() { return "[ScaledLevenstein]"; }

	static public void main(String[] argv) {
		doMain(new ScaledLevenstein(), argv);
	}
}