~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to contrib/fuzzystrmatch/README.fuzzystrmatch

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * fuzzystrmatch.c
 
3
 *
 
4
 * Functions for "fuzzy" comparison of strings
 
5
 *
 
6
 * Joe Conway <mail@joeconway.com>
 
7
 *
 
8
 * Copyright (c) 2001-2005, PostgreSQL Global Development Group
 
9
 * ALL RIGHTS RESERVED;
 
10
 *
 
11
 * levenshtein()
 
12
 * -------------
 
13
 * Written based on a description of the algorithm by Michael Gilleland
 
14
 * found at http://www.merriampark.com/ld.htm
 
15
 * Also looked at levenshtein.c in the PHP 4.0.6 distribution for
 
16
 * inspiration.
 
17
 *
 
18
 * metaphone()
 
19
 * -----------
 
20
 * Modified for PostgreSQL by Joe Conway.
 
21
 * Based on CPAN's "Text-Metaphone-1.96" by Michael G Schwern <schwern@pobox.com>
 
22
 * Code slightly modified for use as PostgreSQL function (palloc, elog, etc).
 
23
 * Metaphone was originally created by Lawrence Philips and presented in article
 
24
 * in "Computer Language" December 1990 issue.
 
25
 *
 
26
 * dmetaphone() and dmetaphone_alt()
 
27
 * ---------------------------------
 
28
 * A port of the DoubleMetaphone perl module by Andrew Dunstan. See dmetaphone.c
 
29
 * for more detail.
 
30
 *
 
31
 * soundex()
 
32
 * -----------
 
33
 * Folded existing soundex contrib into this one. Renamed text_soundex() (C function)
 
34
 * to soundex() for consistency.
 
35
 *
 
36
 * Permission to use, copy, modify, and distribute this software and its
 
37
 * documentation for any purpose, without fee, and without a written agreement
 
38
 * is hereby granted, provided that the above copyright notice and this
 
39
 * paragraph and the following two paragraphs appear in all copies.
 
40
 * 
 
41
 * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
 
42
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
 
43
 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
 
44
 * DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE
 
45
 * POSSIBILITY OF SUCH DAMAGE.
 
46
 * 
 
47
 * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
 
48
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 
49
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 
50
 * ON AN "AS IS" BASIS, AND THE AUTHOR AND DISTRIBUTORS HAS NO OBLIGATIONS TO
 
51
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 
52
 *
 
53
 */
 
54
 
 
55
 
 
56
Version 0.3 (30 June, 2004):
 
57
 
 
58
Release Notes:
 
59
  Version 0.3
 
60
   - added double metaphone code from Andrew Dunstan
 
61
   - change metaphone so that an empty input string causes an empty
 
62
     output string to be returned, instead of throwing an ERROR
 
63
   - fixed examples in README.soundex
 
64
 
 
65
  Version 0.2
 
66
    - folded soundex contrib into this one
 
67
 
 
68
  Version 0.1
 
69
    - initial release    
 
70
 
 
71
Installation:
 
72
  Place these files in a directory called 'fuzzystrmatch' under 'contrib' in the PostgreSQL source tree. Then run:
 
73
 
 
74
    make
 
75
    make install
 
76
 
 
77
  You can use fuzzystrmatch.sql to create the functions in your database of choice, e.g.
 
78
 
 
79
    psql -U postgres template1 < fuzzystrmatch.sql
 
80
 
 
81
  installs following functions into database template1:
 
82
 
 
83
     levenshtein() - calculates the levenshtein distance between two strings
 
84
     metaphone() - calculates the metaphone code of an input string
 
85
 
 
86
Documentation
 
87
==================================================================
 
88
Name
 
89
 
 
90
levenshtein -- calculates the levenshtein distance between two strings
 
91
 
 
92
Synopsis
 
93
 
 
94
levenshtein(text source, text target)
 
95
 
 
96
Inputs
 
97
 
 
98
  source
 
99
    any text string, 255 characters max, NOT NULL
 
100
 
 
101
  target
 
102
    any text string, 255 characters max, NOT NULL
 
103
 
 
104
Outputs
 
105
 
 
106
  Returns int
 
107
 
 
108
Example usage
 
109
 
 
110
  select levenshtein('GUMBO','GAMBOL');
 
111
 
 
112
==================================================================
 
113
Name
 
114
 
 
115
metaphone -- calculates the metaphone code of an input string
 
116
 
 
117
Synopsis
 
118
 
 
119
metaphone(text source, int max_output_length)
 
120
 
 
121
Inputs
 
122
 
 
123
  source
 
124
    any text string, 255 characters max, NOT NULL
 
125
 
 
126
  max_output_length
 
127
    maximum length of the output metaphone code; if longer, the output
 
128
    is truncated to this length
 
129
 
 
130
Outputs
 
131
 
 
132
  Returns text
 
133
 
 
134
Example usage
 
135
 
 
136
  select metaphone('GUMBO',4);
 
137
 
 
138
==================================================================
 
139
-- Joe Conway
 
140