tangentum technologies    
 

Deutsch

   
   
 
    Soundex (Phonetix)
Phonetix
v0.2

com.tangentum.phonetix
Class Soundex

java.lang.Object
  |
  +--com.tangentum.phonetix.PhoneticEncoder
        |
        +--com.tangentum.phonetix.Soundex

public final class Soundex
extends PhoneticEncoder

Encoder implementing the phonetic algorithm "Soundex". Soundex is described in Donald Knuth's The Art of Computer Programming, Vol.3.

Author:
Claus Engel
See Also:
DoubleMetaphone, Metaphone

Field Summary
 
Fields inherited from class com.tangentum.phonetix.PhoneticEncoder
EMPTY_KEYS
 
Constructor Summary
Soundex()
          Constructs an original Soundex encoder which generates keys of length 4.
Soundex(boolean full)
          Constructs a Soundex encoder which generates keys of length 4.
Soundex(boolean full, int length)
          Constructs a Soundex encoder which generates keys of given length.
Soundex(int length)
          Constructs an original Soundex encoder which generates keys of given length.
 
Method Summary
 java.lang.String generateKey(java.lang.String word)
          Returns the encoding of the given word.
 java.lang.String[] generateKeys(java.lang.String word)
          Returns the encoding of the given word.
static void main(java.lang.String[] argv)
          Test of algorithm with default constructed encoder.
 java.lang.String toString()
          Returns a String identifying the algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Soundex

public Soundex(boolean full,
               int length)
Constructs a Soundex encoder which generates keys of given length.

Parameters:
full - a flag which specifies, whether the first character has to to be encoded, or not. If false, then this encoder works like the original soundex described by Knuth, i.e. 'Knuth' will become 'K530'. If true, then this encoder will encode the first character too, i.e. 'Knuth' will become '2530'.
length - the length of the keys to generate.

Soundex

public Soundex(boolean full)
Constructs a Soundex encoder which generates keys of length 4.

Parameters:
full - a flag which specifies, whether the first character has to to be encoded, or not. If false, this encoder works like the original soundex described by Knuth, i.e. 'Knuth' will become 'K530'. If true, this encoder will encode the first character too, i.e. 'Knuth' will become '2530'.

Soundex

public Soundex(int length)
Constructs an original Soundex encoder which generates keys of given length.

Parameters:
length - the length of the keys to generate.

Soundex

public Soundex()
Constructs an original Soundex encoder which generates keys of length 4.

Method Detail

toString

public java.lang.String toString()
Returns a String identifying the algorithm.

Overrides:
toString in class java.lang.Object

generateKeys

public java.lang.String[] generateKeys(java.lang.String word)
Returns the encoding of the given word.

Specified by:
generateKeys in class PhoneticEncoder
Parameters:
word - the word to encode.
Returns:
an array with the encoding of the word. This is never null.

generateKey

public java.lang.String generateKey(java.lang.String word)
Returns the encoding of the given word.

Specified by:
generateKey in class PhoneticEncoder
Parameters:
word - the word to encode.
Returns:
the encoding of the word. This is never null.

main

public static void main(java.lang.String[] argv)
Test of algorithm with default constructed encoder. The encoded arguments are printed to System.out.


Phonetix
v0.2

Copyright © 1996-2003 Claus Engel. All Rights Reserved.