Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: improved levenshtein

by tachyon (Chancellor)
on Mar 04, 2004 at 14:45 UTC ( #333874=note: print w/ replies, xml ) Need Help??


in reply to improved levenshtein

Nice implementation. But I would also suggest that this should patch the existing perl implementation of Text::Levenshtein. Text::LevensteinXS is vanilla C and compiles and installs under 5.6.x on Win32 or Linux. You don't need 5.8 but it comiles with that too. See below. You may find Algorithm::HowSimilar does a very similar job but faster in pure perl.

[root@devel3 perl_modules]# tar -xzf Text-LevenshteinXS-0.01.tar.gz [root@devel3 perl_modules]# cd Text-LevenshteinXS-0.01 [root@devel3 Text-LevenshteinXS-0.01]# perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Text::LevenshteinXS [root@devel3 Text-LevenshteinXS-0.01]# make cp LevenshteinXS.pm blib/lib/Text/LevenshteinXS.pm AutoSplitting blib/lib/Text/LevenshteinXS.pm (blib/lib/auto/Text/Leven +shteinXS) /usr/bin/perl /usr/local/lib/perl5/5.6.2/ExtUtils/xsubpp -typemap /us +r/local/lib/perl5/5.6.2/ExtUtils/typemap LevenshteinXS.xs > Levensht +einXS.xsc && mv LevenshteinXS.xsc LevenshteinXS.c Please specify prototyping behavior for LevenshteinXS.xs (see perlxs m +anual) cc -c -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE +-D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" + -fpic "-I/usr/local/lib/perl5/5.6.2/i686-linux/CORE" LevenshteinXS +.c Running Mkbootstrap for Text::LevenshteinXS () chmod 644 LevenshteinXS.bs rm -f blib/arch/auto/Text/LevenshteinXS/LevenshteinXS.so LD_RUN_PATH="" cc -shared -L/usr/local/lib LevenshteinXS.o -o blib/a +rch/auto/Text/LevenshteinXS/LevenshteinXS.so chmod 755 blib/arch/auto/Text/LevenshteinXS/LevenshteinXS.so cp LevenshteinXS.bs blib/arch/auto/Text/LevenshteinXS/LevenshteinXS.bs chmod 644 blib/arch/auto/Text/LevenshteinXS/LevenshteinXS.bs Manifying blib/man3/Text::LevenshteinXS.3 [root@devel3 Text-LevenshteinXS-0.01]# make test PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl 1..6 # Running under perl version 5.006002 for linux # Current time local: Thu Mar 4 14:36:44 2004 # Current time GMT: Thu Mar 4 14:36:44 2004 # Using Test.pm version 1.24 ok 1 ok 2 ok 3 ok 4 ok 5 ok 6 [root@devel3 Text-LevenshteinXS-0.01]# make install Installing /usr/local/lib/perl5/site_perl/5.6.2/i686-linux/auto/Text/L +evenshteinXS/LevenshteinXS.so Installing /usr/local/lib/perl5/site_perl/5.6.2/i686-linux/auto/Text/L +evenshteinXS/LevenshteinXS.bs Files found in blib/arch: installing files in blib/lib into architectu +re dependent library tree Installing /usr/local/lib/perl5/site_perl/5.6.2/i686-linux/auto/Text/L +evenshteinXS/autosplit.ix Installing /usr/local/lib/perl5/site_perl/5.6.2/i686-linux/Text/Levens +hteinXS.pm Installing /usr/local/man/man3/Text::LevenshteinXS.3 Writing /usr/local/lib/perl5/site_perl/5.6.2/i686-linux/auto/Text/Leve +nshteinXS/.packlist Appending installation info to /usr/local/lib/perl5/5.6.2/i686-linux/p +erllocal.pod [root@devel3 Text-LevenshteinXS-0.01]# perl -v This is perl, v5.6.2 built for i686-linux [snip] [root@devel3 Text-LevenshteinXS-0.01]# D:\Tools\Perl Modules\Text-LevenshteinXS-0.01>perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Text::LevenshteinXS D:\Tools\Perl Modules\Text-LevenshteinXS-0.01>nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cp LevenshteinXS.pm blib\lib\Text\LevenshteinXS.pm AutoSplitting blib\lib\Text\LevenshteinXS.pm (blib\lib\auto\Text\Leven +shteinXS) G:\Perl\bin\Perl.exe -IG:\Perl\lib -IG:\Perl\lib G:\Perl\lib\E +xtUtils/xs ubpp -typemap G:\Perl\lib\ExtUtils\typemap LevenshteinXS.xs > Levensh +teinXS.xsc && G:\Perl\bin\Perl.exe -IG:\Perl\lib -IG:\Perl\lib -MExtUtils::Comma +nd -e mv L evenshteinXS.xsc LevenshteinXS.c Please specify prototyping behavior for LevenshteinXS.xs (see perlxs m +anual) cl -c -nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT + -DHAVE_DE S_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_REA +DFIX -O1 - MD -DNDEBUG -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -IG:\Perl\li +b\CORE Le venshteinXS.c LevenshteinXS.c "Running Mkbootstrap for Text::LevenshteinXS ()" G:\Perl\bin\Perl.exe -IG:\Perl\lib -IG:\Perl\lib -MExtUtils::C +ommand -e chmod 644 LevenshteinXS.bs G:\Perl\bin\Perl.exe "-IG:\Perl\lib" "-IG:\Perl\lib" -MExtUtil +s::Mksymli sts -e "Mksymlists('NAME' => 'Text::LevenshteinXS', 'DLBASE' => 'Leve +nshteinXS' , 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' = +> []);" link -out:blib\arch\auto\Text\LevenshteinXS\LevenshteinXS.dll +-dll -nolo go -nodefaultlib -release -libpath:"G:\Perl\lib\CORE" -machine:x86 L +evenshtein XS.obj G:\Perl\lib\CORE\perl56.lib oldnames.lib kernel32.lib user32. +lib gdi32. lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib olea +ut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc3 +2.lib odbc cp32.lib msvcrt.lib -def:LevenshteinXS.def Creating library blib\arch\auto\Text\LevenshteinXS\LevenshteinXS.li +b and obje ct blib\arch\auto\Text\LevenshteinXS\LevenshteinXS.exp G:\Perl\bin\Perl.exe -IG:\Perl\lib -IG:\Perl\lib -MExtUtils::C +ommand -e chmod 755 blib\arch\auto\Text\LevenshteinXS\LevenshteinXS.dll G:\Perl\bin\Perl.exe -IG:\Perl\lib -IG:\Perl\lib -MExtUtils::C +ommand -e cp LevenshteinXS.bs blib\arch\auto\Text\LevenshteinXS\LevenshteinXS.bs G:\Perl\bin\Perl.exe -IG:\Perl\lib -IG:\Perl\lib -MExtUtils::C +ommand -e chmod 644 blib\arch\auto\Text\LevenshteinXS\LevenshteinXS.bs D:\Tools\Perl Modules\Text-LevenshteinXS-0.01>nmake test Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. G:\Perl\bin\Perl.exe -Iblib\arch -Iblib\lib -IG:\Perl\lib -IG: +\Perl\lib test.pl 1..6 ok 1 ok 2 ok 3 ok 4 ok 5 ok 6 D:\Tools\Perl Modules\Text-LevenshteinXS-0.01>nmake install Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. Installing G:\Perl\site\lib\auto\Text\LevenshteinXS\LevenshteinXS.dll Installing G:\Perl\site\lib\auto\Text\LevenshteinXS\LevenshteinXS.lib Installing G:\Perl\site\lib\auto\Text\LevenshteinXS\LevenshteinXS.exp Installing G:\Perl\site\lib\auto\Text\LevenshteinXS\LevenshteinXS.bs Installing G:\Perl\site\lib\auto\Text\LevenshteinXS\autosplit.ix Installing G:\Perl\site\lib\Text\LevenshteinXS.pm Writing G:\Perl\site\lib\auto\Text\LevenshteinXS\.packlist Appending installation info to G:\Perl\lib/perllocal.pod D:\Tools\Perl Modules\Text-LevenshteinXS-0.01>perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread [snip] D:\Tools\Perl Modules\Text-LevenshteinXS-0.01>

cheers

tachyon


Comment on Re: improved levenshtein
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://333874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2015-07-29 18:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls