Skip to content

Commit 23c29bf

Browse files
committed
testing Levenshtein Distance
1 parent c0c05c3 commit 23c29bf

File tree

5 files changed

+43
-35
lines changed

5 files changed

+43
-35
lines changed

.idea/workspace.xml

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.7 KB
Binary file not shown.
220 Bytes
Binary file not shown.

src/LevenshteinDistance.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ public void Minimum (int a, int b, int c){ // find min between left, top, and di
66
int min = a;
77
if (b < min) {
88
min = b;
9-
}else if (c < min) {
9+
}
10+
if (c < min) {
1011
min = c;
1112
}
1213
this.min = min;
@@ -34,12 +35,12 @@ public void LD (String s, String t){
3435
} // set up rows based off length of n
3536
for (j = 0; j <= m; j++) {
3637
d[0][j] = j;
37-
} // set up rows based off length of m
38+
} // set up columns based off length of m
3839

3940
for (i = 1; i <= n; i++) {
4041
s_i = s.charAt(i - 1);
4142
for (j = 1; j <= m; j++) {
42-
t_j = s.charAt(j - 1);
43+
t_j = t.charAt(j - 1);
4344

4445
if (s_i == t_j){
4546
cost = 0;
@@ -49,7 +50,8 @@ public void LD (String s, String t){
4950

5051
Minimum(d[i - 1][j], d[i - 1][j - 1], d[i][j - 1]);
5152
// cell is based off of cell above,left,and diagonally above and to the left
52-
d[i][j] = (getMin()) + cost;
53+
d[i][j] = getMin() + cost;
54+
System.out.println(getMin() + cost);
5355
}
5456
}
5557
this.finalCost = d[n][m];

src/Main.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ public static void main(String[] args) {
88
// GuessGibberishWord game2 = new GuessGibberishWord();
99
// game2.WordGuessGib(5);
1010
/*------------------------------runs real word guessing game----------------------------------*/
11-
GuessRealWord game3 = new GuessRealWord();
12-
game3.WordGuessReal(2);
11+
// GuessRealWord game3 = new GuessRealWord();
12+
// game3.WordGuessReal(2);
13+
14+
LevenshteinDistance test = new LevenshteinDistance();
15+
test.LD("hello", "helllo");
16+
System.out.println(test.getFinalCost());
17+
18+
1319
} // end main
1420

1521
} // end main class

0 commit comments

Comments
 (0)