summaryrefslogtreecommitdiff
path: root/contrib/soundex
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2001-08-07 18:16:01 +0000
committerBruce Momjian <bruce@momjian.us>2001-08-07 18:16:01 +0000
commitcdd02cdf00f020292cdcc8dafa5475e0149c34a6 (patch)
tree317c5c67dbecac152c6c67766ac86d3f5c8e9536 /contrib/soundex
parentfb5b85a8f2663883f1e3287680dbe0db54e1b617 (diff)
downloadpostgresql-cdd02cdf00f020292cdcc8dafa5475e0149c34a6.tar.gz
Sorry - I should have gotten to this sooner. Here's a patch which you should
be able to apply against what you just committed. It rolls soundex into fuzzystrmatch. Remove soundex/metaphone and merge into fuzzystrmatch. Joe Conway
Diffstat (limited to 'contrib/soundex')
-rw-r--r--contrib/soundex/Makefile40
-rw-r--r--contrib/soundex/README.soundex66
-rw-r--r--contrib/soundex/soundex.c119
-rw-r--r--contrib/soundex/soundex.sql.in5
4 files changed, 0 insertions, 230 deletions
diff --git a/contrib/soundex/Makefile b/contrib/soundex/Makefile
deleted file mode 100644
index 76538e052b..0000000000
--- a/contrib/soundex/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# $Header: /cvsroot/pgsql/contrib/soundex/Attic/Makefile,v 1.10 2001/06/18 21:38:02 momjian Exp $
-#
-
-subdir = contrib/soundex
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-
-NAME := soundex
-SONAME := $(NAME)$(DLSUFFIX)
-
-override CPPFLAGS += -I$(srcdir)
-override CFLAGS += $(CFLAGS_SL)
-override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS)
-
-all: $(SONAME) $(NAME).sql
-
-$(NAME).sql: $(NAME).sql.in
- sed 's,@MODULE_FILENAME@,$(libdir)/contrib/$(SONAME),g' $< >$@
-
-install: all installdirs
- $(INSTALL_SHLIB) $(SONAME) $(libdir)/contrib
- $(INSTALL_DATA) $(NAME).sql $(datadir)/contrib
- $(INSTALL_DATA) README.$(NAME) $(docdir)/contrib
-
-installdirs:
- $(mkinstalldirs) $(libdir)/contrib $(datadir)/contrib $(docdir)/contrib
-
-uninstall:
- rm -f $(libdir)/contrib/$(SONAME) $(datadir)/contrib/$(NAME).sql $(docdir)/contrib/README.$(NAME)
-
-clean distclean maintainer-clean:
- rm -f $(SONAME) $(NAME).o $(NAME).sql
-
-depend dep:
- $(CC) -MM -MG $(CFLAGS) *.c > depend
-
-ifeq (depend,$(wildcard depend))
-include depend
-endif
diff --git a/contrib/soundex/README.soundex b/contrib/soundex/README.soundex
deleted file mode 100644
index a5b1fb3c44..0000000000
--- a/contrib/soundex/README.soundex
+++ /dev/null
@@ -1,66 +0,0 @@
-This directory contains a module that implements the "Soundex" code as
-a PostgreSQL user-defined function. The Soundex system is a method of
-matching similar sounding names (or any words) to the same code. It
-was initially used by the United States Census in 1880, 1900, and
-1910, but it has little use beyond English names (or the English
-pronunciation of names), and it is not a linguistic tool.
-
-To install it, first configure the main source tree, then run make;
-make install in this directory. Finally, load the function definition
-with psql:
-
- psql -f PREFIX/share/contrib/soundex.sql
-
-The following are some usage examples:
-
-SELECT text_soundex('hello world!');
-
-CREATE TABLE s (nm text)\g
-
-insert into s values ('john')\g
-insert into s values ('joan')\g
-insert into s values ('wobbly')\g
-
-select * from s
-where text_soundex(nm) = text_soundex('john')\g
-
-select nm from s a, s b
-where text_soundex(a.nm) = text_soundex(b.nm)
-and a.oid <> b.oid\g
-
-CREATE FUNCTION text_sx_eq(text, text) RETURNS bool AS
-'select text_soundex($1) = text_soundex($2)'
-LANGUAGE 'sql'\g
-
-CREATE FUNCTION text_sx_lt(text,text) RETURNS bool AS
-'select text_soundex($1) < text_soundex($2)'
-LANGUAGE 'sql'\g
-
-CREATE FUNCTION text_sx_gt(text,text) RETURNS bool AS
-'select text_soundex($1) > text_soundex($2)'
-LANGUAGE 'sql';
-
-CREATE FUNCTION text_sx_le(text,text) RETURNS bool AS
-'select text_soundex($1) <= text_soundex($2)'
-LANGUAGE 'sql';
-
-CREATE FUNCTION text_sx_ge(text,text) RETURNS bool AS
-'select text_soundex($1) >= text_soundex($2)'
-LANGUAGE 'sql';
-
-CREATE FUNCTION text_sx_ne(text,text) RETURNS bool AS
-'select text_soundex($1) <> text_soundex($2)'
-LANGUAGE 'sql';
-
-DROP OPERATOR #= (text,text)\g
-
-CREATE OPERATOR #= (leftarg=text, rightarg=text, procedure=text_sx_eq,
-commutator=text_sx_eq)\g
-
-SELECT *
-FROM s
-WHERE text_sx_eq(nm,'john')\g
-
-SELECT *
-from s
-where s.nm #= 'john';
diff --git a/contrib/soundex/soundex.c b/contrib/soundex/soundex.c
deleted file mode 100644
index ff1b0f7aec..0000000000
--- a/contrib/soundex/soundex.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.11 2001/03/22 03:59:10 momjian Exp $ */
-#include "postgres.h"
-
-#include <ctype.h>
-
-#include "fmgr.h"
-#include "utils/builtins.h"
-
-
-Datum text_soundex(PG_FUNCTION_ARGS);
-
-static void soundex(const char *instr, char *outstr);
-
-#define SOUNDEX_LEN 4
-
-
-#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
-#define _textout(str) DatumGetPointer(DirectFunctionCall1(textout, PointerGetDatum(str)))
-
-
-#ifndef SOUNDEX_TEST
-/*
- * SQL function: text_soundex(text) returns text
- */
-PG_FUNCTION_INFO_V1(text_soundex);
-
-Datum
-text_soundex(PG_FUNCTION_ARGS)
-{
- char outstr[SOUNDEX_LEN + 1];
- char *arg;
-
- arg = _textout(PG_GETARG_TEXT_P(0));
-
- soundex(arg, outstr);
-
- PG_RETURN_TEXT_P(_textin(outstr));
-}
-
-#endif /* not SOUNDEX_TEST */
-
-
-/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
-static const char *soundex_table = "01230120022455012623010202";
-
-#define soundex_code(letter) soundex_table[toupper((unsigned char) (letter)) - 'A']
-
-
-static void
-soundex(const char *instr, char *outstr)
-{
- int count;
-
- AssertArg(instr);
- AssertArg(outstr);
-
- outstr[SOUNDEX_LEN] = '\0';
-
- /* Skip leading non-alphabetic characters */
- while (!isalpha((unsigned char) instr[0]) && instr[0])
- ++instr;
-
- /* No string left */
- if (!instr[0])
- {
- outstr[0] = (char) 0;
- return;
- }
-
- /* Take the first letter as is */
- *outstr++ = (char) toupper((unsigned char) *instr++);
-
- count = 1;
- while (*instr && count < SOUNDEX_LEN)
- {
- if (isalpha((unsigned char) *instr) &&
- soundex_code(*instr) != soundex_code(*(instr - 1)))
- {
- *outstr = soundex_code(instr[0]);
- if (*outstr != '0')
- {
- ++outstr;
- ++count;
- }
- }
- ++instr;
- }
-
- /* Fill with 0's */
- while (count < SOUNDEX_LEN)
- {
- *outstr = '0';
- ++outstr;
- ++count;
- }
-}
-
-
-
-#ifdef SOUNDEX_TEST
-int
-main(int argc, char *argv[])
-{
- if (argc < 2)
- {
- fprintf(stderr, "usage: %s string\n", argv[0]);
- return 1;
- }
- else
- {
- char output[SOUNDEX_LEN + 1];
-
- soundex(argv[1], output);
- printf("soundex(%s) = %s\n", argv[1], output);
- return 0;
- }
-}
-
-#endif /* SOUNDEX_TEST */
diff --git a/contrib/soundex/soundex.sql.in b/contrib/soundex/soundex.sql.in
deleted file mode 100644
index 4805694f9a..0000000000
--- a/contrib/soundex/soundex.sql.in
+++ /dev/null
@@ -1,5 +0,0 @@
-CREATE FUNCTION text_soundex(text) RETURNS text
- AS '@MODULE_FILENAME@', 'text_soundex' LANGUAGE 'C';
-
-CREATE FUNCTION soundex(text) RETURNS text
- AS '@MODULE_FILENAME@', 'text_soundex' LANGUAGE 'C';