Doublephone

NAME

Doublephone - Implementation of the Double Metaphone phonetic encoding algorithm.

SYNOPSIS


use Doublephone;

say double-metaphone("SMITH"); # (SM0 XMT)
say double-metaphone("SMIHT"); # (SMT XMT)


DESCRIPTION

This implements the Double Metaphone algorithm which can be used to match similar sounding words. It is an improved version of Metaphone (which in turn follows on from soundex,) and was first described by Lawrence Philips in the June 2000 issue of the C/C++ Users Journal.

It differs from some other similar algorithms in that a primary and secondary code are returned which allows the comparison of words (typically names,) with some common roots in different languages as well as dealing with ambiguities. So for instance "SMITH", "SMYTH" and "SMYTHE" will yield (SM0 XMT) as the primary and secondary, whereas "SCHMIDT", "SCHMIT" will yield (XMT SMT) so if a "cross language" comparison is required then either of the primary or secondary codes can be matched to the target primary or secondary code - this will also deal with, for example, transpositions in typed names.

This is basically a Raku binding to the original C implementation I extracted from the Perl 5 Text::DoubleMetaphone.

ROUTINE

This module exports a single routine that provides the functionality.

routine double-metaphone

sub double-metaphone(Str $word) returns ( Str $primary-code, Str $secondary-code) is export

Given a string to be encoded returns a two element list of the primary and secondary encodings. For any words of the same language with the same consonants in the same order the primary code should be the same, for similar words (possibly in a different language,) the primary or the secondary could should match. A search function could potentially match in such a way that the ones with the same primary code are displayed first, then the (more fuzzy,) secondary matches afterwards.

Doublephone v0.1.2

Implementation of the Double Metaphone phonetic encoding algorithm

Authors

  • Jonathan Stowe

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Doublephone

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.