Re: request a new feature in fuzzystrmatch - Mailing list pgsql-hackers
From | Liming Hu |
---|---|
Subject | Re: request a new feature in fuzzystrmatch |
Date | |
Msg-id | 51973505.1010209@gmail.com Whole thread Raw |
In response to | Re: request a new feature in fuzzystrmatch (Atri Sharma <atri.jiit@gmail.com>) |
Responses |
Re: request a new feature in fuzzystrmatch
|
List | pgsql-hackers |
<div class="moz-cite-prefix">On 5/18/2013 12:11 AM, Atri Sharma wrote:<br /></div><blockquote cite="mid:123A01ED-4073-4389-ACA4-E58AFCA0BABE@gmail.com"type="cite"><pre wrap=""> Sent from my iPad On 18-May-2013, at 12:34, Liming Hu <a class="moz-txt-link-rfc2396E" href="mailto:dawninghu@gmail.com"><dawninghu@gmail.com></a>wrote: </pre><blockquote type="cite"><pre wrap="">On Fri, May 17, 2013 at 11:44 PM, Atri Sharma <a class="moz-txt-link-rfc2396E"href="mailto:atri.jiit@gmail.com"><atri.jiit@gmail.com></a> wrote: </pre><blockquote type="cite"><pre wrap=""> Sent from my iPad On 18-May-2013, at 12:07, Liming Hu <a class="moz-txt-link-rfc2396E" href="mailto:dawninghu@gmail.com"><dawninghu@gmail.com></a>wrote: </pre><blockquote type="cite"><pre wrap="">On Fri, May 17, 2013 at 11:13 PM, Atri Sharma <a class="moz-txt-link-rfc2396E"href="mailto:atri.jiit@gmail.com"><atri.jiit@gmail.com></a> wrote: </pre><blockquote type="cite"><pre wrap=""> Sent from my iPad On 18-May-2013, at 11:23, Liming Hu <a class="moz-txt-link-rfc2396E" href="mailto:dawninghu@gmail.com"><dawninghu@gmail.com></a>wrote: </pre><blockquote type="cite"><pre wrap="">On Fri, May 17, 2013 at 10:21 PM, Atri Sharma <a class="moz-txt-link-rfc2396E"href="mailto:atri.jiit@gmail.com"><atri.jiit@gmail.com></a> wrote: </pre><blockquote type="cite"><pre wrap=""> Sent from my iPad On 18-May-2013, at 10:41, Liming Hu <a class="moz-txt-link-rfc2396E" href="mailto:dawninghu@gmail.com"><dawninghu@gmail.com></a>wrote: </pre><blockquote type="cite"><pre wrap="">On Fri, May 17, 2013 at 9:39 PM, Atri Sharma <a class="moz-txt-link-rfc2396E"href="mailto:atri.jiit@gmail.com"><atri.jiit@gmail.com></a> wrote: </pre><blockquote type="cite"><pre wrap=""> Sent from my iPad On 18-May-2013, at 10:00, Liming Hu <a class="moz-txt-link-rfc2396E" href="mailto:dawninghu@gmail.com"><dawninghu@gmail.com></a>wrote: </pre><blockquote type="cite"><pre wrap="">On 5/17/2013 9:10 PM, Atri Sharma wrote: </pre><blockquote type="cite"><pre wrap="">On Sat, May 18, 2013 at 9:27 AM, Liming Hu <a class="moz-txt-link-rfc2396E" href="mailto:dawninghu@gmail.com"><dawninghu@gmail.com></a>wrote: </pre><blockquote type="cite"><pre wrap="">On 5/17/2013 12:39 PM, Liming Hu wrote: </pre><blockquote type="cite"><pre wrap="">On Fri, May 17, 2013 at 12:06 PM, Josh Berkus <a class="moz-txt-link-rfc2396E"href="mailto:josh@agliodbs.com"><josh@agliodbs.com></a> wrote: </pre><blockquote type="cite"><blockquote type="cite"><pre wrap="">Can we add Levenshtein-Damerau edit distance since itis used in spelling checker instead of levenshtein edit distance? </pre></blockquote><pre wrap="">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(). </pre></blockquote><pre wrap="">I am working on it, I will make it this weekend project. </pre></blockquote><pre wrap=""> I have done that. and put the code at github: <a class="moz-txt-link-freetext" href="https://github.com/liminghu/fuzzystrmatch">https://github.com/liminghu/fuzzystrmatch</a> <a class="moz-txt-link-abbreviated" href="mailto:liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$">liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$</a> sudo cp fuzzystrmatch.so /usr/lib/postgresql/9.1/lib/fuzzystrmatch.so <a class="moz-txt-link-abbreviated" href="mailto:liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$">liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$</a> 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. </pre></blockquote><pre wrap="">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? </pre></blockquote><pre wrap=""> 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: <a class="moz-txt-link-freetext" href="https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--1.0.sql">https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--1.0.sql</a> <a class="moz-txt-link-freetext" href="https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--unpackaged--1.0.sql">https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--unpackaged--1.0.sql</a> <a class="moz-txt-link-freetext" href="https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch.c">https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch.c</a> <a class="moz-txt-link-freetext" href="https://github.com/liminghu/fuzzystrmatch/blob/master/dameraulevenshtein.c">https://github.com/liminghu/fuzzystrmatch/blob/master/dameraulevenshtein.c</a> <a class="moz-txt-link-freetext" href="https://github.com/liminghu/fuzzystrmatch/blob/master/">https://github.com/liminghu/fuzzystrmatch/blob/master/</a> </pre></blockquote><pre wrap=""> You need not reinstall your entire database for installing/re installing an extension.Running make install from the extension'sdirectory(after placing it in /contrib of a postgres database source directory) will install the extension inyour current database without breaking anything. </pre></blockquote><pre wrap=""> You mean: <a class="moz-txt-link-abbreviated" href="mailto:liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$">liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$</a> make install ? </pre></blockquote><pre wrap=""> Yes,although,I would run make clean before running make install,just for ensuring that all runs well. </pre></blockquote><pre wrap=""> <a class="moz-txt-link-abbreviated" href="mailto:liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$">liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$</a> sudo make clean rm -f fuzzystrmatch.so libfuzzystrmatch.a rm -f fuzzystrmatch.o dmetaphone.o <a class="moz-txt-link-abbreviated" href="mailto:liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$">liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$</a> 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/' <a class="moz-txt-link-abbreviated" href="mailto:liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$">liming@liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$</a> 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 </pre></blockquote><pre wrap=""> 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. </pre><blockquote type="cite"><pre wrap=""> </pre></blockquote><pre wrap=""> It seems that the functions you added are not being created in the database.Are you sure that you have modified the .SQLfiles 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 oneof the original functions of fuzzystrmatch,to ensure that the original functionalities are still working? </pre></blockquote><pre wrap=""> 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 </pre></blockquote><pre wrap=""> The files will be copied to your pkglibdir path, which you can find by running pg_config --pkglibdir </pre></blockquote><pre wrap=""> 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. </pre></blockquote><pre wrap=""> (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 makeit from source? </pre></blockquote><br /> I am running ubuntu, I install postgresql from the ubuntu software center.<br /> I directly copythose files, now it works. <br /><br /><p style="margin:0in;font-family:consolas;font-size:11.0pt">select dameraulevenshteinnocompatible('cta','cat',1,1,1,1);<p style="margin:0in;font-family:consolas;font-size:11.0pt"> <p style="margin:0in;font-family:consolas;font-size:11.0pt">1<br/><p style="margin:0in;font-family:consolas;font-size:11.0pt"><br/> thanks a lot.<br /><p style="margin:0in;font-family:consolas;font-size:11.0pt">Liming<br/><br /><blockquote cite="mid:123A01ED-4073-4389-ACA4-E58AFCA0BABE@gmail.com"type="cite"><pre wrap=""> Regards, Atri </pre><blockquote type="cite"><pre wrap=""> </pre></blockquote></blockquote><br />
pgsql-hackers by date: