Back in 1918, in the US, a patent was given to whatever passed as nerds back then, who invented an algorithm for finding similar sounding names and words, such as John and Jon or Schmitt and Schmidt.
Back in the days and only working with the names common in the US at the time (thing was made for the census) the SOUNDEX algorithm has aged a bit and certainly not transported well to foreign languages.
In some countries, other nerds found new ways of doing it (Kölner Phonetic in Germany for example) but many of those were geared towards the specific target market.
Nowadays, with the percentage of people with migratory background rising everywhere, it has become more difficult to perform this task.
To the rescue : Phonet and it’s posh sibling Phonet2.
As a quick look into the 4D documentation will tell you, there is no such thing in 4D, so we need to roll our own.
Another quick google further and we find the algorithm definition and pseudo code for it…
Well, challenge accepted!
I hereby offer the brotherhood of 4D developers my absolutely genius Phonet component:
Just drop it into your components folder, there is just one command you shall call:
It requires 2 parameters :
- the text to be phonetted or phonet2etted (is that a verb? now it is!)
- true to use phonet2, false to use plain phonet
and it returns the phonetted (new adjective!) string.
some quick and lazy examples:
As for testing: just launch the component by itself and it will display this stunningly complex but intricately designed dialog:enter the strings to compare in the top fields and see the magic happen…
Hope you enjoy this, and always grateful for donations towards my Aston Martin fund…
Well, i’m done here, so here you go:
PS: The source is in the component package should you be interested in the innards of this thing…