Computing a phonetic code

If we're dealing with a corpus of English words, then we can categorize them into phonetic codes to see how similar they sound. Phonetic codes work for any alphabetical strings, not just actual words. We will use the Text.PhoneticCode package to compute the Soundex and Phoneix phonetic codes. The package documentation can be found on Hackage at http://hackage.haskell.org/package/phonetic-code.

Getting ready

Install the phonetic code library from Cabal as follows:

$ cabal install phonetic-code

How to do it...

  1. Import the phonetic code functions as follows:
    import Text.PhoneticCode.Soundex (soundexNARA, soundexSimple)
    import Text.PhoneticCode.Phonix (phonix)
  2. Define a list of similar-sounding words as follows:
    ws = ["haskell", ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.