home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 May
/
Chip_2000-05_cd1.bin
/
zkuste
/
Perl
/
ActivePerl-5.6.0.613.msi
/
䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥
/
_f1deac30178ad5ccf397ebdf43fa93e5
< prev
next >
Wrap
Text File
|
2000-03-23
|
5KB
|
115 lines
<HTML>
<HEAD>
<TITLE>Text::Soundex - Implementation of the Soundex Algorithm as Described by Knuth</TITLE>
<LINK REL="stylesheet" HREF="../../Active.css" TYPE="text/css">
<LINK REV="made" HREF="mailto:">
</HEAD>
<BODY>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> Text::Soundex - Implementation of the Soundex Algorithm as Described by Knuth</P></STRONG>
</TD></TR>
</TABLE>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<LI><A HREF="#examples">EXAMPLES</A></LI>
<LI><A HREF="#limitations">LIMITATIONS</A></LI>
<LI><A HREF="#author">AUTHOR</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>Text::Soundex - Implementation of the Soundex Algorithm as Described by Knuth</P>
<P>
<HR>
<H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
<UL>
<LI>Linux</LI>
<LI>Solaris</LI>
<LI>Windows</LI>
</UL>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
use Text::Soundex;</PRE>
<PRE>
$code = soundex $string; # get soundex code for a string
@codes = soundex @list; # get list of codes for list of strings</PRE>
<PRE>
# set value to be returned for strings without soundex code</PRE>
<PRE>
$soundex_nocode = 'Z000';</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>This module implements the soundex algorithm as described by Donald Knuth
in Volume 3 of <STRONG>The Art of Computer Programming</STRONG>. The algorithm is
intended to hash words (in particular surnames) into a small space using a
simple model which approximates the sound of the word when spoken by an English
speaker. Each word is reduced to a four character string, the first
character being an upper case letter and the remaining three being digits.</P>
<P>If there is no soundex code representation for a string then the value of
<CODE>$soundex_nocode</CODE> is returned. This is initially set to <A HREF="../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A>, but
many people seem to prefer an <EM>unlikely</EM> value like <CODE>Z000</CODE>
(how unlikely this is depends on the data set being dealt with.) Any value
can be assigned to <CODE>$soundex_nocode</CODE>.</P>
<P>In scalar context <CODE>soundex</CODE> returns the soundex code of its first
argument, and in array context a list is returned in which each element is the
soundex code for the corresponding argument passed to <CODE>soundex</CODE> e.g.</P>
<PRE>
@codes = soundex qw(Mike Stok);</PRE>
<P>leaves <CODE>@codes</CODE> containing <CODE>('M200', 'S320')</CODE>.</P>
<P>
<HR>
<H1><A NAME="examples">EXAMPLES</A></H1>
<P>Knuth's examples of various names and the soundex codes they map to
are listed below:</P>
<PRE>
Euler, Ellery -> E460
Gauss, Ghosh -> G200
Hilbert, Heilbronn -> H416
Knuth, Kant -> K530
Lloyd, Ladd -> L300
Lukasiewicz, Lissajous -> L222</PRE>
<P>so:</P>
<PRE>
$code = soundex 'Knuth'; # $code contains 'K530'
@list = soundex qw(Lloyd Gauss); # @list contains 'L300', 'G200'</PRE>
<P>
<HR>
<H1><A NAME="limitations">LIMITATIONS</A></H1>
<P>As the soundex algorithm was originally used a <STRONG>long</STRONG> time ago in the US
it considers only the English alphabet and pronunciation.</P>
<P>As it is mapping a large space (arbitrary length strings) onto a small
space (single letter plus 3 digits) no inference can be made about the
similarity of two strings which end up with the same soundex code. For
example, both <CODE>Hilbert</CODE> and <CODE>Heilbronn</CODE> end up with a soundex code
of <CODE>H416</CODE>.</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>This code was implemented by Mike Stok (<CODE>stok@cybercom.net</CODE>) from the
description given by Knuth. Ian Phillips (<CODE>ian@pipex.net</CODE>) and Rich Pinder
(<CODE>rpinder@hsc.usc.edu</CODE>) supplied ideas and spotted mistakes.</P>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> Text::Soundex - Implementation of the Soundex Algorithm as Described by Knuth</P></STRONG>
</TD></TR>
</TABLE>
</BODY>
</HTML>