Permalink
Browse files

Initial revision

git-svn-id: http://svn.schwern.org/repos/CPAN/Text-Metaphone/trunk@2986 8151f2b9-fde8-0310-94fd-f048d12aab9e
  • Loading branch information...
1 parent e9fa8d8 commit e8320fc2829eaa7990d72e8585e3256e14230e29 schwern committed Dec 8, 2000
Showing with 1,207 additions and 0 deletions.
  1. +57 −0 Changes
  2. +25 −0 INSTALL
  3. +16 −0 MANIFEST
  4. +57 −0 Makefile.PL
  5. +129 −0 Metaphone.pm
  6. +126 −0 Metaphone.xs
  7. +48 −0 README
  8. +33 −0 metachar.h
  9. +43 −0 metaphone.h
  10. +388 −0 metaphone_c.c
  11. +100 −0 my_memory.c
  12. +79 −0 my_memory.h
  13. +35 −0 myconsts.h
  14. +18 −0 mytypes.h
  15. +51 −0 t/metaphone.t
  16. +2 −0 typemap
View
@@ -0,0 +1,57 @@
+Revision history for Perl extension Text::Metaphone.
+
+0.01 Tue Dec 2 05:15:49 1997
+ - original version; created by h2xs 1.18
+
+0.02 Tue Dec 2 10:18:27 EST 1997
+ - First release to CPAN.
+ - Added POD documentation.
+ - MaxPhonemeLen is no longer exported.
+
+Heh, what happened to 1.00? Never existed, it was supposed to be the gamma
+release of the pure perl version of the module. Skipped straight to 1.90,
+alpha XS version.
+
+BTW The new XS version is about 40x faster than the old perl version. :)
+
+1.90 Mon Jan 4 03:20:00 EST 1999
+ - First working XS
+ - Has memory leak
+ - Fixed Schw bug
+ * Alterations to algorithm:
+ SCHW -> X 'Schwern', 'Schwartz'
+ SCH -> SK 'School'
+
+1.91 Mon Jan 4 21:00:00 EST 1999
+ - Fixed memory leak
+ - Started POD
+
+1.92 Tue Jan 5 21:44:11 EST 1999
+ * Alterations to API
+ removed Text::Soundex emulation layer
+ removed everything but Metaphone()
+ * Alterations to algorithm:
+ CHR -> KR 'Christ', 'tchrist'
+ - Finished POD
+ - First CPAN release since 0.02
+
+
+1.93 Thu Jan 21 21:34:40 EST 1999
+ * Removed empty string asseration.
+ * Fixed "W if followed by a vowel" (Thanks to Paul Walmsley)
+ * Fixed "Ignore C if SC[IEY]"
+ * Fixed array boundry problems in ENCODE.
+
+
+1.94 Fri Jan 22 15:26:30 EST 1999
+ - Defined NULL for myself. Fixes bug on SunOS 4.1.x
+
+1.95 Wed Jan 27 15:02:47 EST 1999
+ * Fixed 'CK'->'KK' bug. ('CK' is now 'K')
+ - Added README and INSTALL docs
+ - Moved test.pl to t/metaphone.t
+
+1.96 Thu Mar 4 18:44:02 EST 1999
+ - DumbFS fix, changed metaphone.c to metaphone_c.c so that
+ the XS generated file Metaphone.c does not conflict with
+ it on case-insensitive filesystems. (Thanks Pudge)
View
@@ -0,0 +1,25 @@
+WHAT IS THIS?
+
+This is Text::Metaphone, a perl module. Please see the README that comes with
+this distribution.
+
+HOW DO I INSTALL IT?
+
+To install this module, cd to the directory that contains this README
+file and type the following:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+To install this module into a specific directory, do:
+ perl Makefile.PL PREFIX=/name/of/the/directory
+ ...the rest is the same...
+
+Please also read the perlmodinstall man page, if available.
+
+WHAT EXTRAS DO I NEED?
+
+ An ANSI C compiler
+
View
@@ -0,0 +1,16 @@
+Changes
+MANIFEST
+Makefile.PL
+Metaphone.pm
+Metaphone.xs
+metachar.h
+metaphone_c.c
+metaphone.h
+my_memory.c
+my_memory.h
+myconsts.h
+mytypes.h
+t/metaphone.t
+README
+INSTALL
+typemap
View
@@ -0,0 +1,57 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+
+eval {
+ require Text::Metaphone;
+};
+
+unless ($@) { # Make sure we did find the module.
+ print <<CHANGE_WARN if $Text::Metaphone::VERSION < 1.00;
+
+NOTE: There have been API changes between this version and any
+older than version 1.00! Also, the metaphone algorithm has been
+modified. Please read the Changes file if you are upgrading from
+a version of Text::Metaphone older than 1.00.
+
+CHANGE_WARN
+
+
+ print <<FIX_WARN if($Text::Metaphone::VERSION >= 1.00 && $Text::Metaphone::VERSION <= 1.94);
+
+NOTE: Bugs fixed in this version alter the way Text::Metaphone encodes
+certain words. If you have stored metaphone encodings using your
+older version of T::M, please re-encode them with this new version.
+Please read the Changes file for details.
+
+FIX_WARN
+}
+
+WriteMakefile(
+ 'NAME' => 'Text::Metaphone',
+ 'VERSION_FROM' => 'Metaphone.pm', # finds $VERSION
+# 'LIBS' => [''], # e.g., '-lm'
+# 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
+# 'INC' => '', # e.g., '-I/usr/include/other'
+ 'C' => ['metaphone_c.c my_memory.c'],
+ 'OBJECT' => 'metaphone_c.o my_memory.o Metaphone.o',
+ 'dist' => {COMPRESS => 'gzip -9',
+ SUFFIX => '.gz',
+ DIST_DEFAULT => 'all tardist',
+ },
+#CCFLAGS => '-Dbool=char -DHAS_BOOL -I/usr/local/include -Wall -pedantic',
+#OPTIMIZE => '-g',
+);
+
+sub MY::postamble {
+'
+metaphone_c.o: mytypes.h myconsts.h my_memory.o metachar.h metaphone.h metaphone_c.c
+
+my_memory.o: mytypes.h myconsts.h my_memory.c my_memory.h
+'
+}
+
+
+
+
+
View
@@ -0,0 +1,129 @@
+package Text::Metaphone;
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
+
+require Exporter;
+require DynaLoader;
+
+use integer;
+
+@ISA = qw(Exporter DynaLoader);
+
+@EXPORT = qw(
+ Metaphone
+);
+
+$VERSION = 1.96;
+
+bootstrap Text::Metaphone $VERSION;
+
+# I should probably do this in XS, too...
+sub Metaphone {
+ my($word, $len) = @_;
+ my($phoned);
+ $len = 0 unless defined $len;
+ metaphone($word, $len, $phoned);
+ return $phoned;
+}
+
+1;
+
+__END__
+=pod
+
+=head1 NAME
+
+Text::Metaphone - A modern soundex. Phonetic encoding of words.
+
+
+=head1 SYNOPSIS
+
+ use Text::Metaphone;
+ $phoned_words = Metaphone('Schwern');
+
+
+=head1 DESCRIPTION
+
+C<Metaphone()> is a function whereby a string/word is broken down into
+a rough approximation of its english phonetic pronunciation. Very
+similar in concept and purpose to soundex, but much more
+comprehensive in its approach.
+
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item B<Metaphone>
+
+ $phoned_word = Metaphone($word, $max_phone_len);
+
+Takes a word and encodes it according to the Metaphone algorithm.
+The algorithm only deals with alphabetical characters, all else is ignored.
+
+If $max_phone_len is provided, Metaphone will only encode up to that many
+characters for each word.
+
+'sh' is encoded as 'X', 'th' is encoded as '0'. This can be changed
+in the metaphone.h header file.
+
+=back
+
+
+=head1 CAVEATS
+
+=over 4
+
+=item Metaphone algorithm changes
+
+I have made a few minor changes to the traditional metaphone algorithm found
+in the books. The most significant one is that it will differenciate between
+SCH and SCHW making the former K (As in School) and the latter sh (as in
+Schwartz and Schwern).
+
+My changes can be turned off by defining the USE_TRADITIONAL_METAPHONE
+flag in metaphone.h.
+
+Due to these changes, any users of Metaphone v1.00 or earlier which have stored
+metaphonetic encodings, they should recalculate those with the new verison.
+
+
+=head1 AUTHOR
+
+Michael G Schwern <schwern@pobox.com>
+
+=head1 SEE ALSO
+
+=head2 Man pages
+
+L<Text::Soundex>
+
+=head2 Books, Journals and Magazines
+
+=over 3
+
+=item Binstock, Andrew & Rex, John. "Metaphone: A Modern Soundex." I<Practical Algorithms For Programmers.> Reading, Mass: Addion-Wesley, 1995 pp160-169
+
+Contains an explaination of the basic metaphone concept & algorithm and C code
+from which I learned of Metaphone and ported this module.
+
+=item Parker, Gary. "A Better Phonetic Search." I<C Gazette>, Vol. 5, No. 4 (June/July), 1990.
+
+This is the public-domain C version of metaphone from which Binstock & Rex
+based their own.. I haven't actually read it.
+
+=item Philips, Lawrence. I<Computer Language>, Vol. 7, No. 12 (December), 1990.
+
+And here's the original Metaphone algorithm as presented in Pick BASIC.
+
+=back
+
+=head1 COPYRIGHT, et al.
+
+Copyright (c) 1997-1999 Michael G Schwern. All Rights Reserved.
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut
+
Oops, something went wrong.

0 comments on commit e8320fc

Please sign in to comment.