Description

Metaphone 'sounds like' algorithm

Author

Kon Lovett

Version

Requires

Usage

(require-extension metaphone)

Download

metaphone.egg

Documentation

Supplies an implementation of Lawrence Philips' Double Metaphone algorithm. A 'sounds like' string -> search key utility, similar to Soundex but with better match and worse computational performance. Strings must conform to English spelling yet are not limited to English words.

Checked API

METAPHONE-INTEGER-KEYLEN-MAXIMUM The maximum key length for conversion to an integer representation. A shorter value will result in faster key generation but possibly less reliable matching.

procedure: (make-metaphone-key TARGET [#:keylen METAPHONE-INTEGER-KEYLEN-MAXIMUM] [#:keyint? #t])

Returns an object comprising the Double Metaphone interpretation of the TARGET string.

keylen: A positive integer. The maximum length of the result key.
keyint?: A boolean. Active only when key length is <= METAPHONE-INTEGER-KEYLEN-MAXIMUM.

An integer key can only compared with another integer key. Do not use the integer key option unless the programmer is prepared to ensure this situation.

procedure: (*make-metaphone-key PRIMARY [ALTERNATE])

Returns a metaphone-key object, with field values supplied as arguments. The arguments must have originally been the result of the metaphone-key object getters.

Useful when metaphone keys must be stored or transmitted externally.

procedure: (metaphone-key? OBJECT)

Is the OBJECT a metaphone key?

procedure: (metaphone-key-primary KEY)

The primary key, a string, or, when a integer key, an integer.

procedure: (metaphone-key-alternate KEY)

The alternate key, a string, or, when a integer key, an integer, or, when no alternate, #f.

procedure: (metaphone-key-integer? KEY)

Was integer encoding used to construct this metaphone key?

procedure: (metaphone-key-compare KEY1 KEY2)

Returns the strength of the match, [0 3], with 3 the strongest and 0 no match.

procedure: (metaphone-key=? KEY1 KEY2)

Do the keys match at some non-zero strength?

procedure: (metaphone-key-equal? VALUE1 VALUE2)

Do the key values equal?

procedure: (metaphone-key-hash VALUE)

Returns a hash value for the key value.

Unchecked API

procedure: (%metaphone-key-compare KEY1 KEY2)

Returns the strength of the match, [0 3], with 3 the strongest and 0 no match.

procedure: (%metaphone-key=? KEY1 KEY2)

Do the keys match at some non-zero strength?

procedure: (%metaphone-key-equal-procedure KEYINT?)

Returns the 2 argument procedure for the equality test of the specified key type.

procedure: (%metaphone-key-hash-procedure KEYINT?)

Returns the 2 argument hash procedure of the specified key type.

Examples

; See "metaphone-test.scm" in the egg.

License

Copyright (c) 2006, Kon Lovett.  All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the Software),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.