<font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Olá Daniel Marcelino, precisaria de uma ajuda sua no soundex.</font></font></font><div><font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Verifiquei que erros de digitação não são captados pelo SoundexBR.</font></font></font></div>
<div><font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Exemplo:</font></font></font></div><div><font face="arial, helvetica, sans-serif">?MARIA e MARIA, PE8DRO e PEDRO.</font></div><div><font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Será que seria tranquilo para você implementar algumas coisas?</font></font></font></div>
<div><font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Estou enviando um script que fiz com teste para alguns caracteres.</font></font></font></div><div><font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Desde já muito obrigada.</font></font></font></div>
<div><font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Abs</font></font></font></div><div><font color="#993399"><font size="4"><font face="comic sans ms,sans-serif">Fátima</font></font></font></div>
<div><div><font face="arial, helvetica, sans-serif">soundexBR<-function(termo){</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-toupper(termo)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 1. Retire toda pontuação da palavra;</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-gsub("[ÃÁÀÂÄ]","A",termo)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-gsub("[ÉÈÊ?Ë]","E",termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-gsub("[ÍÌÏÎI]","I",termo)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-gsub("[ÓÕÒÔÖ]","O",termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-gsub("[ÚÙÛÜU]","U",termo)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-gsub("Ç","C",termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>#1.a Substituir todas as letras duplas por uma única letra</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>#<a href="http://www.archives.gov/genealogy/census/soundex.html">http://www.archives.gov/genealogy/census/soundex.html</a></font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>termo<-gsub("([A-Z])\\1", "\\1", termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 2. Fique com a primeira letra;</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> N<-nchar(termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># Modificação PT-BR (Coeli e Camargo)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-ifelse(substr(termo,1,2)=="WA",sub("W","V",termo),termo)</font></div><div>
<font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-ifelse(substr(termo,1,1)=="H",substr(termo,2,N),termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-ifelse(substr(termo,1,2)=="KA"|substr(termo,1,2)=="KO"|substr(termo,1,2)=="KU",sub("K","C",termo),termo)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-ifelse(substr(termo,1,1)=="Y",sub("Y","I",termo),termo)</font></div><div>
<font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-ifelse(substr(termo,1,2)=="CE"|substr(termo,1,2)=="CI",sub("C","S",termo),termo)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-ifelse(substr(termo,1,2)=="GE"|substr(termo,1,2)=="GI",sub("G","J",termo),termo)<span class="Apple-tab-span" style="white-space:pre"> </span> </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>############## Segunda Parte #######################<span class="Apple-tab-span" style="white-space:pre"> </span> </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo.1<-substr(termo,1,1)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-substr(termo,2,N)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 3. Mude todas as ocorrências das letras a seguir por '0' (zero): 'A','E','I','O','U','H','W','Y';</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("[A,E,I,O,U,H,W,Y]",0,termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 4. Mude as letras restantes de acordo com a tabela abaixo: </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># Número<span class="Apple-tab-span" style="white-space:pre"> </span>Letra </font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 1<span class="Apple-tab-span" style="white-space:pre"> </span>'B','F','P','V'</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("[B,F,P,V]",1,termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 2<span class="Apple-tab-span" style="white-space:pre"> </span>'C','G','J','K', 'Q','S','X','Z'</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("[C,G,J,K,Q,S,X,Z]",2,termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 3<span class="Apple-tab-span" style="white-space:pre"> </span>'D','T'</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("[D,T]",3,termo) </font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 4<span class="Apple-tab-span" style="white-space:pre"> </span>'L' </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("L",4,termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 5<span class="Apple-tab-span" style="white-space:pre"> </span>'M','N' </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("[M,N]",5,termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 6<span class="Apple-tab-span" style="white-space:pre"> </span>'R'</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("R",6,termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 5. Remova todos os zeros da string resultante;</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub(0,"",termo)</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># Eliminar dois numeros iguais consecutivos por um único numero </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>#<a href="http://www.archives.gov/genealogy/census/soundex.html">http://www.archives.gov/genealogy/census/soundex.html</a></font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-gsub("([0-9])\\1", "\\1", termo) </font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># Remontar </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-paste(termo.1,termo,sep="")</font></div><div><font face="arial, helvetica, sans-serif"> </font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span># 6. Preencha a string resultante com zeros à direita e retorne desta forma: </font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span>#<letra maiuscula><digito><digito><digito></font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-paste(termo,"0000",sep="")</font></div><div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> termo<-substr(termo,1,4)</font></div>
<div><font face="arial, helvetica, sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span> return(termo)</font></div><div><font face="arial, helvetica, sans-serif">} </font></div><div><font face="arial, helvetica, sans-serif"><br>
</font></div><div><font face="arial, helvetica, sans-serif">soundexBR("termo")</font></div><div><font face="arial, helvetica, sans-serif">soundexBR("terno")</font></div><div><font face="arial, helvetica, sans-serif"><br>
</font></div><div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER?D","HARTMUT","RALF","STEFAN","ROBERT"))</font></div><div><font face="arial, helvetica, sans-serif">nomea</font></div>
<div><font face="arial, helvetica, sans-serif">nomeb=data.frame(nome=c("HARTMUT","GERD","ROBERT","STEFAN","RALF"))</font></div><div><font face="arial, helvetica, sans-serif">nomeb</font></div>
<div><font face="arial, helvetica, sans-serif">fonoa=soundexBR(nomea$nome)</font></div><div><font face="arial, helvetica, sans-serif">fonob=soundexBR(nomeb$nome)</font></div><div><font face="arial, helvetica, sans-serif">library(RecordLinkage)</font></div>
<div><font face="arial, helvetica, sans-serif">pairs.mat = outer(fonoa,fonob, "==")</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat</font></div><div><font face="arial, helvetica, sans-serif">#Ponto de interrogação</font></div>
<div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER?D","HARTMUT","?RALF","STEFAN","ROBERT"))</font></div><div><font face="arial, helvetica, sans-serif">nomea</font></div>
<div><font face="arial, helvetica, sans-serif">nomeb=data.frame(nome=c("HARTMUT?","GERD","ROBERT","STEFAN","RALF"))</font></div><div><font face="arial, helvetica, sans-serif">nomeb</font></div>
<div><font face="arial, helvetica, sans-serif">fonoa=soundexBR(nomea$nome)</font></div><div><font face="arial, helvetica, sans-serif">fonob=soundexBR(nomeb$nome)</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat = outer(fonoa,fonob, "==")</font></div>
<div><font face="arial, helvetica, sans-serif">pairs.mat</font></div><div><font face="arial, helvetica, sans-serif">#Não funciona com o ? no início</font></div><div><font face="arial, helvetica, sans-serif">###############################################################################</font></div>
<div><font face="arial, helvetica, sans-serif">#Barras inclinadas /</font></div><div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER/D","/HARTMUT","RALF/","STEFAN","ROBERT"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomea</font></div><div><font face="arial, helvetica, sans-serif">nomeb=data.frame(nome=c("HARTMUT","GERD","ROBERT","STEFAN","RALF"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomeb</font></div><div><font face="arial, helvetica, sans-serif">fonoa=soundexBR(nomea$nome)</font></div><div><font face="arial, helvetica, sans-serif">fonob=soundexBR(nomeb$nome)</font></div>
<div><font face="arial, helvetica, sans-serif">pairs.mat = outer(fonoa,fonob, "==")</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat</font></div><div><font face="arial, helvetica, sans-serif">#Não funciona com a barra inclinada</font></div>
<div><font face="arial, helvetica, sans-serif">#Barras inclinadas \</font></div><div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER\D","\HARTMUT","RALF\","STEFAN","ROBERT"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomea</font></div><div><font face="arial, helvetica, sans-serif">#O R rejeita a \</font></div><div><font face="arial, helvetica, sans-serif">#Parênteses (</font></div><div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER(D","(HARTMUT","RALF(","STEFA)N","ROBERT)"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomea</font></div><div><font face="arial, helvetica, sans-serif">nomeb=data.frame(nome=c("HARTMUT","GERD","ROBERT","STEFAN","RALF"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomeb</font></div><div><font face="arial, helvetica, sans-serif">fonoa=soundexBR(nomea$nome)</font></div><div><font face="arial, helvetica, sans-serif">fonob=soundexBR(nomeb$nome)</font></div>
<div><font face="arial, helvetica, sans-serif">pairs.mat = outer(fonoa,fonob, "==")</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat</font></div><div><font face="arial, helvetica, sans-serif">#Só funciona com o parênteses depois do nome</font></div>
<div><font face="arial, helvetica, sans-serif">#Dois pontos e ponto e vírgula</font></div><div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER:D",":HARTMUT","RALF:","STEFA;N","ROBERT;"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomea</font></div><div><font face="arial, helvetica, sans-serif">nomeb=data.frame(nome=c("HARTMUT","GERD","ROBERT","STEFAN","RALF"))</font></div>
<div><font face="arial, helvetica, sans-serif">fonob=soundexBR(nomeb$nome)</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat = outer(fonoa,fonob, "==")</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat</font></div>
<div><font face="arial, helvetica, sans-serif">#Só funciona com o : e ; depois do nome</font></div><div><font face="arial, helvetica, sans-serif">#Dólar e ponto</font></div><div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER$D","%HARTMUT","RALF%","STEFA.N","ROBERT."))</font></div>
<div><font face="arial, helvetica, sans-serif">nomeb=data.frame(nome=c("HARTMUT","GERD","ROBERT","STEFAN","RALF"))</font></div><div><font face="arial, helvetica, sans-serif">nomeb</font></div>
<div><font face="arial, helvetica, sans-serif">fonoa=soundexBR(nomea$nome)</font></div><div><font face="arial, helvetica, sans-serif">fonob=soundexBR(nomeb$nome)</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat = outer(fonoa,fonob, "==")</font></div>
<div><font face="arial, helvetica, sans-serif">pairs.mat</font></div><div><font face="arial, helvetica, sans-serif">#Idem </font></div><div><font face="arial, helvetica, sans-serif">#Números</font></div><div><font face="arial, helvetica, sans-serif">nomea=data.frame(nome=c("GER1D","2HARTMUT","RALF3","S4TEFA.N","RO5BERT6"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomea</font></div><div><font face="arial, helvetica, sans-serif">nomeb=data.frame(nome=c("HARTMUT","GERD","ROBERT","STEFAN","RALF"))</font></div>
<div><font face="arial, helvetica, sans-serif">nomeb</font></div><div><font face="arial, helvetica, sans-serif">fonoa=soundexBR(nomea$nome)</font></div><div><font face="arial, helvetica, sans-serif">fonob=soundexBR(nomeb$nome)</font></div>
<div><font face="arial, helvetica, sans-serif">pairs.mat = outer(fonoa,fonob, "==")</font></div><div><font face="arial, helvetica, sans-serif">pairs.mat</font></div><div><font face="arial, helvetica, sans-serif">#Não funciona com números</font></div>
<div style="color:rgb(153,51,153);font-size:large;font-family:'comic sans ms',sans-serif"><br></div></div>