Re: request a new feature in fuzzystrmatch

Поиск
Список
Период
Сортировка
От Atri Sharma
Тема Re: request a new feature in fuzzystrmatch
Дата
Msg-id CAOeZVif94D4CeLVYe55AyxYbTsPKPus5NrkqV04gFQMT9548Bg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: request a new feature in fuzzystrmatch  (Liming Hu <dawninghu@gmail.com>)
Ответы Re: request a new feature in fuzzystrmatch
Список pgsql-hackers
On Sat, May 18, 2013 at 1:30 PM, Liming Hu <dawninghu@gmail.com> wrote:
> On 5/18/2013 12:11 AM, Atri Sharma wrote:
>
> Sent from my iPad
>
> On 18-May-2013, at 12:34, Liming Hu <dawninghu@gmail.com> wrote:
>
> On Fri, May 17, 2013 at 11:44 PM, Atri Sharma <atri.jiit@gmail.com> wrote:
>
> Sent from my iPad
>
> On 18-May-2013, at 12:07, Liming Hu <dawninghu@gmail.com> wrote:
>
> On Fri, May 17, 2013 at 11:13 PM, Atri Sharma <atri.jiit@gmail.com> wrote:
>
> Sent from my iPad
>
> On 18-May-2013, at 11:23, Liming Hu <dawninghu@gmail.com> wrote:
>
> On Fri, May 17, 2013 at 10:21 PM, Atri Sharma <atri.jiit@gmail.com> wrote:
>
> Sent from my iPad
>
> On 18-May-2013, at 10:41, Liming Hu <dawninghu@gmail.com> wrote:
>
> On Fri, May 17, 2013 at 9:39 PM, Atri Sharma <atri.jiit@gmail.com> wrote:
>
> Sent from my iPad
>
> On 18-May-2013, at 10:00, Liming Hu <dawninghu@gmail.com> wrote:
>
> On 5/17/2013 9:10 PM, Atri Sharma wrote:
>
> On Sat, May 18, 2013 at 9:27 AM, Liming Hu <dawninghu@gmail.com> wrote:
>
> On 5/17/2013 12:39 PM, Liming Hu wrote:
>
> On Fri, May 17, 2013 at 12:06 PM, Josh Berkus <josh@agliodbs.com> wrote:
>
> Can we add Levenshtein-Damerau edit distance since it is used in
> spelling checker
> instead of levenshtein edit distance?
>
> Patches welcome!  You, too, can be a PostgreSQL contributor.
>
> However, you will need to preserve the ability of users to use the old
> levenshtien algorithm as well, for backwards-compatibility.  Shouldn't
> be hard, just add a new function called levenshtiend().
>
> I am working on it, I will make it this weekend project.
>
> I have done that. and put the code at github:
> https://github.com/liminghu/fuzzystrmatch
>
> liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
> sudo cp fuzzystrmatch.so
> /usr/lib/postgresql/9.1/lib/fuzzystrmatch.so
> liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
> sudo /etc/init.d/postgresql restart
>
> * Restarting PostgreSQL 9.1 database server
>
> [ OK ]
>
>
> select dameraulevenshteinnocompatible('cta', 'cat',1,1,1,1);
> CREATE EXTENSION fuzzystrmatch;
>
> ********** Error **********
>
> ERROR: could not load library
> "/usr/lib/postgresql/9.1/lib/fuzzystrmatch.so":
> /usr/lib/postgresql/9.1/lib/fuzzystrmatch.so: undefined symbol:
> damerau_levenshtein_internal_noncompatible
>
> Any one can help me on this? Thanks.
>
> The system is not able to find the required library, and I dont think
> using cp to place the library is a very good idea.Did you run Make
> Install after you added your work in the Makefile?
>
> I did not run make install. I am running a stable postgresql in my laptop, I
> do not
> want to reinstall everything, just want to try this contribution.  I am
> afraid
> reinstall it will destroy my configurations, and databases, just do not want
> to mess up.
> did you see any thing wrong:
> https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--1.0.sql
> https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--unpackaged--1.0.sql
> https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch.c
> https://github.com/liminghu/fuzzystrmatch/blob/master/dameraulevenshtein.c
> https://github.com/liminghu/fuzzystrmatch/blob/master/
>
>
> You need not reinstall your entire database for installing/re installing an
> extension.Running make install from the extension's directory(after placing
> it in /contrib of a postgres database source directory) will install the
> extension in your current database without breaking anything.
>
> You mean:
> liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
> make install
> ?
>
> Yes,although,I would run make clean before running make install,just for
> ensuring that all runs well.
>
> liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
> sudo make clean
> rm -f fuzzystrmatch.so   libfuzzystrmatch.a
> rm -f fuzzystrmatch.o dmetaphone.o
> liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
> sudo make install
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Wendif-labels -Wformat-security
> -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fpic -I. -I.
> -I../../src/include -D_GNU_SOURCE   -c -o fuzzystrmatch.o
> fuzzystrmatch.c
> In file included from fuzzystrmatch.c:250:0:
> dameraulevenshtein.c: In function ‘damerau_levenshtein_internal’:
> dameraulevenshtein.c:290:57: warning: unused variable ‘trans’
> [-Wunused-variable]
> dameraulevenshtein.c:328:57: warning: unused variable ‘trans’
> [-Wunused-variable]
> In file included from fuzzystrmatch.c:253:0:
> dameraulevenshtein.c: In function ‘damerau_levenshtein_less_equal_internal’:
> dameraulevenshtein.c:290:57: warning: unused variable ‘trans’
> [-Wunused-variable]
> dameraulevenshtein.c:328:57: warning: unused variable ‘trans’
> [-Wunused-variable]
> dameraulevenshtein.c: In function
> ‘dameraulevenshtein_with_costs_noncompatible’:
> dameraulevenshtein.c:480:9: warning: ISO C90 forbids mixed
> declarations and code [-Wdeclaration-after-statement]
> dameraulevenshtein.c:494:10: warning: ISO C90 forbids mixed
> declarations and code [-Wdeclaration-after-statement]
> fuzzystrmatch.c: In function ‘damerau_levenshtein_with_costs_noncompatible’:
> fuzzystrmatch.c:266:2: warning: implicit declaration of function
> ‘damerau_levenshtein_internal_noncompatible’
> [-Wimplicit-function-declaration]
> fuzzystrmatch.c: At top level:
> dameraulevenshtein.c:40:12: warning: ‘dameraulevenshtein_internal’
> declared ‘static’ but never defined [-Wunused-function]
> dameraulevenshtein.c:37:12: warning:
> ‘dameraulevenshtein_less_equal_internal’ declared ‘static’ but never
> defined [-Wunused-function]
> dameraulevenshtein.c:464:12: warning:
> ‘dameraulevenshtein_with_costs_noncompatible’ defined but not used
> [-Wunused-function]
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Wendif-labels -Wformat-security
> -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fpic -I. -I.
> -I../../src/include -D_GNU_SOURCE   -c -o dmetaphone.o dmetaphone.c
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Wendif-labels -Wformat-security
> -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fpic -shared
> -o fuzzystrmatch.so fuzzystrmatch.o dmetaphone.o -L../../src/port
> -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags
> /bin/mkdir -p '/usr/local/pgsql/lib'
> /bin/mkdir -p '/usr/local/pgsql/share/extension'
> /bin/mkdir -p '/usr/local/pgsql/share/extension'
> /bin/sh ../../config/install-sh -c -m 755  fuzzystrmatch.so
> '/usr/local/pgsql/lib/fuzzystrmatch.so'
> /bin/sh ../../config/install-sh -c -m 644 ./fuzzystrmatch.control
> '/usr/local/pgsql/share/extension/'
> /bin/sh ../../config/install-sh -c -m 644 ./fuzzystrmatch--1.0.sql
> ./fuzzystrmatch--unpackaged--1.0.sql
> '/usr/local/pgsql/share/extension/'
> liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
>
>
> After that:
>
> CREATE EXTENSION fuzzystrmatch;
> select dameraulevenshteinnocompatible('cta', 'cat',1,1,1,1);
>
>
>
>
> ERROR:  function dameraulevenshteinnocompatible(unknown, unknown,
> integer, integer, integer, integer) does not exist
> LINE 1: select dameraulevenshteinnocompatible('cta', 'cat',1,1,1,1);
>             ^
> HINT:  No function matches the given name and argument types. You
> might need to add explicit type casts.
>
>
> ********** Error **********
>
> ERROR: function dameraulevenshteinnocompatible(unknown, unknown,
> integer, integer, integer, integer) does not exist
> SQL state: 42883
> Hint: No function matches the given name and argument types. You might
> need to add explicit type casts.
> Character: 8
>
>
>
> Ok,so now, we are in issues with the code and possibly, the configurations.
>
> First up, I would fix the warnings
> that are being generated while compiling.Those may lead to hard to detect
> errors later on.
>
> It seems that the functions you added are not being created in the
> database.Are you sure that you have modified the .SQL files correctly to
> create you functions as well,and that you are using the correct SQL files
> while installing?
>
> Does this happen only with dameraulevenshteinnocompatible, or with every
> function that you added? Have you tried using one of the original functions
> of fuzzystrmatch,to ensure that the original functionalities are still
> working?
>
>
> it seems the make install command will copy fuzzystrmatch.so to:
> liming@liming-UX31A:/usr/local/pgsql/lib$ ls -la
> total 48
> drwxr-xr-x 2 root root  4096 May 17 23:14 .
> drwxr-xr-x 4 root root  4096 May 17 22:39 ..
> -rwxr-xr-x 1 root root 40640 May 17 23:14 fuzzystrmatch.so
>
> liming@liming-UX31A:/usr/local/pgsql/share/extension$ ls -la
> total 28
> drwxr-xr-x 2 root root 4096 May 17 23:14 .
> drwxr-xr-x 3 root root 4096 May 17 22:39 ..
> -rw-r--r-- 1 root root 2250 May 17 22:48 fuzzystrmatch--1.0.sql
> -rw-r--r-- 1 root root 2250 May 17 23:14 fuzzystrmatch--1.1.sql
> -rw-r--r-- 1 root root  175 May 17 23:14 fuzzystrmatch.control
> -rw-r--r-- 1 root root 1945 May 17 22:48 fuzzystrmatch--unpackaged--1.0.sql
> -rw-r--r-- 1 root root 1945 May 17 23:14 fuzzystrmatch--unpackaged--1.1.sql
>
> instead of:
>
> liming@liming-UX31A:/usr/local/pgsql/lib$ ls -la
> /usr/lib/postgresql/9.1/lib/fuzzystrmatch.so
> -rw-r--r-- 1 root root 30520 May 17 19:50
> /usr/lib/postgresql/9.1/lib/fuzzystrmatch.so
>
>
> The files will be copied to your pkglibdir path, which you can find by
> running pg_config --pkglibdir
>
> pg_config
> You need to install postgresql-server-dev-X.Y for building a
> server-side extension or libpq-dev for building a client-side
> application.
>
>
> (Please keep the list marked in your replies).
>
> How did you install the Postgres instance you are trying to install the
> extension in? Did you use pre built binaries or make it from source?
>
>
> I am running ubuntu, I install postgresql from the ubuntu software center.
> I directly copy those files, now it works.
>
> select dameraulevenshteinnocompatible('cta', 'cat',1,1,1,1);
>
>
>
> 1
>
>
> thanks a lot.
>
> Liming
>
>
> Regards,
>
> Atri
>
>

Awesome.

For reference, if you are using pre built binaries(as you are using),
you should install the client side applications and
postgresql-server-dev-X.Y as well.

Regards,

Atri
--
Regards,

Atri
l'apprenant



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Liming Hu
Дата:
Сообщение: Re: request a new feature in fuzzystrmatch
Следующее
От: Liming Hu
Дата:
Сообщение: Re: request a new feature in fuzzystrmatch