From 8477ea244be967dce76dc8addb29437a05aea6ef Mon Sep 17 00:00:00 2001 From: Ben Fifield Date: Fri, 2 Jun 2017 09:34:17 -0400 Subject: [PATCH] up changes to debug --- R/dedupeMatches.R | 10 +++++++--- R/nameReweight.R | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/R/dedupeMatches.R b/R/dedupeMatches.R index 793abfb..1ac840c 100644 --- a/R/dedupeMatches.R +++ b/R/dedupeMatches.R @@ -80,13 +80,17 @@ dedupeMatches <- function(matchesA, matchesB, EM, matchesLink, ## Get matches if(stringdist.match[i]){ if(stringdist.method %in% c("jw", "jaro")){ - p1 <- ifelse(stringdist.method == "jw", jw.weight, NULL) + if(stringdist.method == "jw"){ + p1 <- jw.weight + }else{ + p1 <- NULL + } tmp <- 1 - stringdist(matchesA[,varnames[i]], matchesB[,varnames[i]], "jw", p = p1) }else{ - t <- stringdistmatrix(matchesA[,varnames[i]], matchesB[,varnames[i]], method = stringdist.method) + t <- stringdist(matchesA[,varnames[i]], matchesB[,varnames[i]], method = stringdist.method) t.1 <- nchar(matchesA[,varnames[i]]) t.2 <- nchar(matchesB[,varnames[i]]) - o <- t(apply(t.1, 1, function(w){ ifelse(w >= t.2, w, t.2)})) + o <- ifelse(t.1 > t.2, t.1, t.2) tmp <- 1 - t * (1/o) } if(partial.match[i]){ diff --git a/R/nameReweight.R b/R/nameReweight.R index 1f2a657..0acbf9a 100644 --- a/R/nameReweight.R +++ b/R/nameReweight.R @@ -99,13 +99,17 @@ nameReweight <- function(dfA, dfB, EM, gammalist, matchesLink, ## Get matches if(stringdist.match[i]){ if(stringdist.method %in% c("jw", "jaro")){ - p1 <- ifelse(stringdist.method == "jw", jw.weight, NULL) + if(stringdist.method == "jw"){ + p1 <- jw.weight + }else{ + p1 <- NULL + } tmp <- 1 - stringdist(matchesA[,varnames[i]], matchesB[,varnames[i]], "jw", p = p1) }else{ - t <- stringdistmatrix(matchesA[,varnames[i]], matchesB[,varnames[i]], method = stringdist.method) + t <- stringdist(matchesA[,varnames[i]], matchesB[,varnames[i]], method = stringdist.method) t.1 <- nchar(matchesA[,varnames[i]]) t.2 <- nchar(matchesB[,varnames[i]]) - o <- t(apply(t.1, 1, function(w){ ifelse(w >= t.2, w, t.2)})) + o <- ifelse(t.1 > t.2, t.1, t.2) tmp <- 1 - t * (1/o) } if(partial.match[i]){