File: Metaphone.pm

package info (click to toggle)
libtext-metaphone-perl 20160805-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 124 kB
  • ctags: 25
  • sloc: ansic: 269; perl: 91; makefile: 3
file content (115 lines) | stat: -rw-r--r-- 2,857 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package Text::Metaphone;

use strict;
use warnings;

require Exporter;
require DynaLoader;

use integer;

our @ISA = qw(Exporter DynaLoader);

our @EXPORT = qw(
    Metaphone
);

our $VERSION = '20160805';

bootstrap Text::Metaphone $VERSION;

1;

__END__
=pod

=head1 NAME

Text::Metaphone - A modern soundex.  Phonetic encoding of words.

=head1 SYNOPSIS

  use Text::Metaphone;

  # XWRN
  my $phoned_word = 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

=head3 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.


=head1 CAVEATS

=head3 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 version.


=head1 AUTHOR

Michael G Schwern <schwern@pobox.com>

=head1 SEE ALSO

=head2 Man pages

L<Text::Soundex> - A simpler word hashing algorithm
L<Text::DoubleMetaphone> - Improved metaphone
L<Text::Phonetic> - A collection of phonetic algorithms

=head2 Books, Journals and Magazines

=head3 Binstock, Andrew & Rex, John. "Metaphone:  A Modern Soundex." I<Practical Algorithms For Programmers.>  Reading, Mass:  Addion-Wesley, 1995  pp160-169 

Contains an explanation of the basic metaphone concept & algorithm and C code
from which I learned of Metaphone and ported this module.

=head3 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.

=head3 Philips, Lawrence. I<Computer Language>, Vol. 7, No. 12 (December), 1990.  

And here's the original Metaphone algorithm as presented in Pick BASIC.


=head1 COPYRIGHT and LICENSE

Copyright (c) 1997, 1999, 2007-2008 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