Comments (4)
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.
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.
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.
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)
- fatal error: my_global.h: No such file or directory HOT 5
- Unable to create function after compiling library: Error: Can't find symbol 'levenshtein' in library HOT 8
- Error with MYSql 8 HOT 1
- Build with MariaDB 10.3+ failed HOT 2
- Does not build (MySQL 8 issue maybe?) HOT 3
- Can't find symbol 'levenshtein' in library HOT 1
- Expand unittests
- Unable to create function after compiling library: Error: Can't find symbol 'levenshtein' in library HOT 1
- Implement levenshtein_ratio_k
- Clean code HOT 1
- Re-create old algorithm's description in blog HOT 1
- compilation on macosX HOT 3
- Wrong memory allocation with init? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from levenshtein-mysql-udf.