com.wallstreetwise.core.util
Class Phonetics

java.lang.Object
  extended by com.wallstreetwise.core.util.Phonetics

public class Phonetics
extends java.lang.Object

This class is used to create the phonetic codes that JSpell uses for its dictionary files.


Field Summary
static char[] unicodeMap
          A mapping of all UNICODE characters to a simplified format.
 
Constructor Summary
Phonetics()
           
 
Method Summary
static double eqscore(java.lang.String x, java.lang.String y, boolean accents)
          Calculate an equivalency or similarity ranking on two strings.
static double eqscore(java.lang.String s1, java.lang.String s2, char weightmode, boolean accents)
          Calculate an equivalency score for two strings.
static void main(java.lang.String[] args)
          A test interface for the Phonetics class.
static char reduce(char origChar)
          Reduce Unicode characters to an ASCII form for equivalency ranking.
static java.lang.String replace(java.lang.String target, java.lang.String from, java.lang.String to)
          Replace all occurrences of a string within a string with another string.
static java.lang.String soundex_en(java.lang.String in, boolean padcode)
          Calculate English Soundex codes.
static java.lang.String soundex_es(java.lang.String in, boolean padcode)
          Calculate Spanish Soundex codes.
static java.lang.String soundex_fr(java.lang.String in, boolean padcode, int specialFlag)
          Calculate French Soundex values.
static java.lang.String soundex(java.lang.String in)
          Calculate Soundex value for a string.
static java.lang.String soundex(java.lang.String in, boolean padcode, java.lang.String language, int specialFlag)
          Calculate a Soundex code.
static java.lang.String soundex(java.lang.String in, java.lang.String language, int specialFlag)
          Calculate a Soundex code for a specific language, e.g., French, Spanish and English have different Soundex algorithms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unicodeMap

public static final char[] unicodeMap
A mapping of all UNICODE characters to a simplified format.

Constructor Detail

Phonetics

public Phonetics()
Method Detail

eqscore

public static final double eqscore(java.lang.String x,
                                   java.lang.String y,
                                   boolean accents)
Calculate an equivalency or similarity ranking on two strings.

Parameters:
x - a String.
y - a String.
accents - true or false
Returns:
a double.

eqscore

public static final double eqscore(java.lang.String s1,
                                   java.lang.String s2,
                                   char weightmode,
                                   boolean accents)
Calculate an equivalency score for two strings. Specify an optional weight mode to skew suggestions based on an internal formula. Contact The Solution Cafe for more information.

Parameters:
s1 - a String.
s2 - a String.
weightmode - a char.
accents - true or false.
Returns:
a double

reduce

public static final char reduce(char origChar)
Reduce Unicode characters to an ASCII form for equivalency ranking. These codes are taken from Unicode Standard 3.0 Latin-1 Supplement. Characters are processed in the following order: Letter Frequency in the English Language (18584 Common Base Words) "no plural words or words with common suffixes" e a i r t o n s l c u p m d h g b y f v w k x z q j

Parameters:
origChar - a char.
Returns:
a char.

soundex

public static java.lang.String soundex(java.lang.String in)
Calculate Soundex value for a string.

Parameters:
in - a String.
Returns:
a String.

soundex

public static java.lang.String soundex(java.lang.String in,
                                       java.lang.String language,
                                       int specialFlag)
Calculate a Soundex code for a specific language, e.g., French, Spanish and English have different Soundex algorithms.

Parameters:
in - a String.
language - a String.
specialFlag - true or false
Returns:
a String.

soundex

public static final java.lang.String soundex(java.lang.String in,
                                             boolean padcode,
                                             java.lang.String language,
                                             int specialFlag)
Calculate a Soundex code.

Parameters:
in - a String.
padcode - true or false
language - a String
specialFlag - an int.
Returns:
a String.

soundex_fr

public static final java.lang.String soundex_fr(java.lang.String in,
                                                boolean padcode,
                                                int specialFlag)
Calculate French Soundex values.

Parameters:
in - a String.
padcode - true or false.
specialFlag - an int.
Returns:
a String.

soundex_es

public static final java.lang.String soundex_es(java.lang.String in,
                                                boolean padcode)
Calculate Spanish Soundex codes.

Parameters:
in - a String.
padcode - true or false.
Returns:
a String.

soundex_en

public static final java.lang.String soundex_en(java.lang.String in,
                                                boolean padcode)
Calculate English Soundex codes.

Parameters:
in - a String.
padcode - true or false.
Returns:
a String.

replace

public static java.lang.String replace(java.lang.String target,
                                       java.lang.String from,
                                       java.lang.String to)
Replace all occurrences of a string within a string with another string.

Parameters:
target - a String.
from - a String.
to - a String.
Returns:
a String.

main

public static void main(java.lang.String[] args)
A test interface for the Phonetics class.

Parameters:
args - Test method. Not documented.


JSpell SDK 2004 Spell Checker for the Java (tm) Platform
Copyright © 1996-2005 The Solution Cafe Inc, All Rights Reserved - http://www.thesolutioncafe.com