Last change
on this file since 1311 was
1311,
checked in by rkrimmel, 11 years ago
|
Initial svn migration from wrong repository
|
File size:
831 bytes
|
Rev | Line | |
---|
[1311] | 1 | /** |
---|
| 2 | * |
---|
| 3 | */ |
---|
| 4 | package de.ugoe.cs.autoquest.plugin.alignment; |
---|
| 5 | |
---|
| 6 | /** |
---|
| 7 | * @author Ralph Krimmel |
---|
| 8 | * |
---|
| 9 | */ |
---|
| 10 | public class NearbySubstitutionMatrix implements SubstitutionMatrix { |
---|
| 11 | |
---|
| 12 | private int[] input1; |
---|
| 13 | private int[] input2; |
---|
| 14 | private int range; |
---|
| 15 | |
---|
| 16 | public NearbySubstitutionMatrix(int[] input1,int[] input2, int range) { |
---|
| 17 | this.input1 = input1; |
---|
| 18 | this.input2 = input2; |
---|
| 19 | this.range = range; |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | /* (non-Javadoc) |
---|
| 23 | * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) |
---|
| 24 | */ |
---|
| 25 | public double getDistance(int pos1, int pos2) { |
---|
| 26 | int difference = Math.abs(input1[pos1]-input2[pos2]); |
---|
| 27 | if(difference < range) { |
---|
| 28 | return range-difference; |
---|
| 29 | } |
---|
| 30 | else { |
---|
| 31 | return -range; |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | @Override |
---|
| 37 | public double getGapPenalty() { |
---|
| 38 | return -range-1; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | @Override |
---|
| 42 | public String info() { |
---|
| 43 | return "Range: " + range; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.