| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 788cf5d commit 0a960c4
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,6 @@ | |||
| 1 | + version 0.9.3 | ||
| 2 | + - bugfix in dl, lv, osa distance: weights were not taken into account properly (thanks to Zach Price) | ||
| 3 | + | ||
| 1 | 4 | version 0.9.2 | |
| 2 | 5 | - Update fixing some errors (missing documentation, tests) in the 0.9.1 release. | |
| 3 | 6 | - Fixed a few possible memory leaks. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -184,6 +184,7 @@ SEXP R_amatch(SEXP x, SEXP table, SEXP method | |||
| 184 | 184 | , p | |
| 185 | 185 | , q | |
| 186 | 186 | ); | |
| 187 | + | ||
| 187 | 188 | double d = R_PosInf, d1 = R_PosInf; | |
| 188 | 189 | int index, len_X, len_T; | |
| 189 | 190 | unsigned int *str; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -135,14 +135,14 @@ double dl_dist( | |||
| 135 | 135 | /* j = tgt index */ | |
| 136 | 136 | for(i=1;i<=x;i++){ | |
| 137 | 137 | uniquePush(dict,src[i]); | |
| 138 | - scores[(i+1) * (y + 2) + 1] = i; | ||
| 138 | + scores[(i+1) * (y + 2) + 1] = i * weight[0]; | ||
| 139 | 139 | scores[(i+1) * (y + 2) + 0] = score_ceil; | |
| 140 | 140 | swapCount = 0; | |
| 141 | 141 | ||
| 142 | 142 | for(j=1;j<=y;j++){ | |
| 143 | 143 | if(i == 1) { | |
| 144 | 144 | uniquePush(dict,tgt[j]); | |
| 145 | - scores[1 * (y + 2) + (j + 1)] = j; | ||
| 145 | + scores[1 * (y + 2) + (j + 1)] = j * weight[0]; | ||
| 146 | 146 | scores[0 * (y + 2) + (j + 1)] = score_ceil; | |
| 147 | 147 | } | |
| 148 | 148 | targetCharCount = dict->value[which(dict, tgt[j-1])]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,12 +43,11 @@ double lv_dist( | |||
| 43 | 43 | int I = na+1, L = na+1, J = nb+1; | |
| 44 | 44 | double sub; | |
| 45 | 45 | ||
| 46 | - | ||
| 47 | 46 | for ( i = 0; i < I; ++i ){ | |
| 48 | - scores[i] = i; | ||
| 47 | + scores[i] = i * weight[0]; | ||
| 49 | 48 | } | |
| 50 | 49 | for ( j = 1; j < J; ++j, L += I ){ | |
| 51 | - scores[L] = j; | ||
| 50 | + scores[L] = j * weight[0]; | ||
| 52 | 51 | } | |
| 53 | 52 | ||
| 54 | 53 | int M; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,10 +41,10 @@ double osa_dist(unsigned int *a, int na, unsigned int *b, int nb, double *weight | |||
| 41 | 41 | double sub, tran; | |
| 42 | 42 | ||
| 43 | 43 | for ( i = 0; i < I; ++i ){ | |
| 44 | - scores[i] = i; | ||
| 44 | + scores[i] = i * weight[0]; | ||
| 45 | 45 | } | |
| 46 | 46 | for ( j = 1; j < J; ++j, L += I ){ | |
| 47 | - scores[L] = j; | ||
| 47 | + scores[L] = j * weight[0]; | ||
| 48 | 48 | } | |
| 49 | 49 | ||
| 50 | 50 | for ( i = 1; i <= na; ++i ){ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,6 +55,25 @@ test_that("weights are handled correctly",{ | |||
| 55 | 55 | stringdist("abc","ac",method='osa',weight=c(0.5,1,1,1)), | |
| 56 | 56 | stringdist("ac","abc",method='osa',weight=c(1,0.5,1,1)) | |
| 57 | 57 | ) | |
| 58 | + expect_equal( | ||
| 59 | + stringdist("ABC", "BC", method = "lv", weight = c(i=.1, d=.1, s=.1)),.1 | ||
| 60 | + ) | ||
| 61 | + expect_equal( | ||
| 62 | + stringdist("ABC", "BC", method = "lv", weight = c(i=.1, d=.1, s=1)),.1 | ||
| 63 | + ) | ||
| 64 | + | ||
| 65 | + expect_equal( | ||
| 66 | + stringdist("ABC", "BC", method = "osa", weight = c(i=.1, d=.1, s=.1,t=.1)),.1 | ||
| 67 | + ) | ||
| 68 | + expect_equal( | ||
| 69 | + stringdist("ABC", "BC", method = "osa", weight = c(i=.1, d=.1, s=1,t=.1)),.1 | ||
| 70 | + ) | ||
| 71 | + expect_equal( | ||
| 72 | + stringdist("ABC", "BC", method = "dl", weight = c(i=.1, d=.1, s=.1,t=.1)),.1 | ||
| 73 | + ) | ||
| 74 | + expect_equal( | ||
| 75 | + stringdist("ABC", "BC", method = "dl", weight = c(i=.1, d=.1, s=1,t=.1)),.1 | ||
| 76 | + ) | ||
| 58 | 77 | }) | |
| 59 | 78 | ||
| 60 | 79 | test_that("NA's are handled correctly",{ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments