Git Product home page Git Product logo

Comments (4)

ppazos avatar ppazos commented on July 23, 2024
mysql> CREATE FUNCTION levenshtein RETURNS INT SONAME 'levenshtein.so';
ERROR 1126 (HY000): Can't open shared library 'levenshtein.so' (errno: 2 /usr/lib/mysql/plugin/levenshtein.so: cannot open shared object file: No such file or directory)

After build, there is the need to copy the .so file to the location mentioned on the error above.

$ sudo cp levenshtein.so /usr/lib/mysql/plugin/

mysql> CREATE FUNCTION levenshtein RETURNS INT SONAME 'levenshtein.so';
Query OK, 0 rows affected (0.00 sec)

from levenshtein-mysql-udf.

ppazos avatar ppazos commented on July 23, 2024

Just to confirm:

mysql>  select * from mysql.func;
+---------------------+-----+----------------+----------+
| name                | ret | dl             | type     |
+---------------------+-----+----------------+----------+
| levenshtein         |   2 | levenshtein.so | function |
| levenshtein_k       |   2 | levenshtein.so | function |
| levenshtein_k_ratio |   2 | levenshtein.so | function |
| levenshtein_ratio   |   2 | levenshtein.so | function |
+---------------------+-----+----------------+----------+

Testing: there is an error: levenshtein_ratio returns the same as levenshtein instead of 0..1


mysql> select levenshtein_ratio('MARIO','mario');
+------------------------------------+
| levenshtein_ratio('MARIO','mario') |
+------------------------------------+
|                                  5 |
+------------------------------------+
1 row in set (0.00 sec)

mysql> select levenshtein_ratio('Mario','mario');
+------------------------------------+
| levenshtein_ratio('Mario','mario') |
+------------------------------------+
|                                  1 |
+------------------------------------+
1 row in set (0.00 sec)

mysql> select levenshtein('Mario','mario');
+------------------------------+
| levenshtein('Mario','mario') |
+------------------------------+
|                            1 |
+------------------------------+
1 row in set (0.00 sec)

mysql> select levenshtein('MARIO','mario');
+------------------------------+
| levenshtein('MARIO','mario') |
+------------------------------+
|                            5 |
+------------------------------+
1 row in set (0.00 sec)

from levenshtein-mysql-udf.

ppazos avatar ppazos commented on July 23, 2024

In fact, all functions return the same as levenshtein, here tested lev_k_ratio:

mysql> select levenshtein_k_ratio('mario','Mario',1);
+----------------------------------------+
| levenshtein_k_ratio('mario','Mario',1) |
+----------------------------------------+
|                                      1 |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select levenshtein_k_ratio('mario','mArio',1);
+----------------------------------------+
| levenshtein_k_ratio('mario','mArio',1) |
+----------------------------------------+
|                                      1 |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select levenshtein('mario','mArio');
+------------------------------+
| levenshtein('mario','mArio') |
+------------------------------+
|                            1 |
+------------------------------+
1 row in set (0.00 sec)

from levenshtein-mysql-udf.

ppazos avatar ppazos commented on July 23, 2024

The only way to make the ratio work is by using levenshtein() /* the only function that works from mysql */ and calculating the ratio:

mysql> select (1- levenshtein('mario','Mario') / GREATEST(LENGTH('mario'), LENGTH('Mario')));
+--------------------------------------------------------------------------------+
| (1- levenshtein('mario','Mario') / GREATEST(LENGTH('mario'), LENGTH('Mario'))) |
+--------------------------------------------------------------------------------+
|                                                                         0.8000 |
+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)

from levenshtein-mysql-udf.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.