Message-ID: <CAN2xGJa5=vLDA0EGh52JD9bgfj6S_heLHF0rQoO7zNpXyGNcRg@mail.gmail.com>
Date: 2016-12-14T19:42:14Z
From: Dimitri Liakhovitski
Subject: weird behavior of DoubleMetaphone
In-Reply-To: <CAN2xGJZmLWOv3Fdtw1imx3OVs-x9SVmSM-rbp79Rjd6=UBa5Lg@mail.gmail.com>
No real need to answer. I found that function 'metaphone' from package
"phonics" doesn't misbehave this way!
library(phonics)
mymetaphone = function(x){
temp <- strsplit(x, split=" ")[[1]]
for(word in 1:length(temp)){
temp[word]<-metaphone(temp[word])
}
return(paste(temp, collapse = ""))
}
The next 4 lines return the same thing:
metaphone("netflix")
metaphone("net flex")
mymetaphone("netflix")
mymetaphone("net flex")
Dimitri
On Wed, Dec 14, 2016 at 2:35 PM, Dimitri Liakhovitski
<dimitri.liakhovitski at gmail.com> wrote:
> I was wondering if anyone can answer this question.
>
> library(PGRdup)
>
> Both lines below return "NTFL".
> DoubleMetaphone("netflix")$primary
> DoubleMetaphone("net flex")$primary
>
> Now, I modify the function a bit - I first split the string on
> "space", then merge back together:
>
> mymetaphone = function(x){
> temp <- strsplit(x, split=" ")[[1]]
> for(word in 1:length(temp)){
> temp[word]<-DoubleMetaphone(temp[word])$primary
> }
> return(paste(temp, collapse = ""))
> }
> mymetaphone("netflix") # returns "NTFL"
> mymetaphone("net flex") # returns "NTFLKS"
>
> Why such a difference between DoubleMetaphone("net flex")$primary and
> mymetaphone("net flex")?
> Why isn't DoubleMetaphone("net flex")$primary returning "NTFLKS"?
> Thank you!
>
> --
> Dimitri Liakhovitski
--
Dimitri Liakhovitski