-
Notifications
You must be signed in to change notification settings - Fork 5
/
LevDistance.java
32 lines (24 loc) · 1020 Bytes
/
LevDistance.java
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
29
30
31
32
package org.genericsystem.cv.model;
import org.genericsystem.api.core.annotations.Components;
import org.genericsystem.api.core.annotations.SystemGeneric;
import org.genericsystem.api.core.annotations.constraints.PropertyConstraint;
import org.genericsystem.common.Generic;
import org.genericsystem.cv.Levenshtein;
import org.genericsystem.cv.model.ZoneText.ZoneTextInstance;
@SystemGeneric
@PropertyConstraint
@Components({ ZoneText.class, ZoneText.class })
public class LevDistance implements Generic {
public static class LevDistanceInstance implements Generic {
public ZoneTextInstance getFirstZoneText() {
return (ZoneTextInstance) this.getComponent(0);
}
public ZoneTextInstance getSecondZoneText() {
return (ZoneTextInstance) this.getComponent(1);
}
}
public LevDistanceInstance computeLevDistance(ZoneTextInstance zt1, ZoneTextInstance zt2) {
int d = Levenshtein.distance((String) zt1.getValue(), (String) zt2.getValue());
return (LevDistanceInstance) setInstance(d, zt1, zt2);
}
}