Matcher Rust Implement C FFI bindings
Overview
A high-performance matcher designed to solve LOGICAL and TEXT VARIATIONS problems in word matching, implemented in Rust.
Installation
Build from source
git clone https://github.com/Lips7/Matcher.git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly -y
cargo build --release
Then you should find the libmatcher_c.so/libmatcher_c.dylib/matcher_c.dll in the target/release directory.
Install pre-built binary
Visit the release page to download the pre-built binary.
Python usage example
## define ffi
=
=
# init matcher
=
# check is match
# True
# match as list
=
# [{"match_id":1,"table_id":1,"word_id":0,"word":"hello,world","similarity":1.0},{"match_id":1,"table_id":1,"word_id":1,"word":"hello","similarity":1.0},{"match_id":1,"table_id":1,"word_id":2,"word":"world","similarity":1.0}]
# match as dict
=
# {"1":[{"match_id":1,"table_id":1,"word_id":0,"word":"hello,world","similarity":1.0},{"match_id":1,"table_id":1,"word_id":1,"word":"hello","similarity":1.0},{"match_id":1,"table_id":1,"word_id":2,"word":"world","similarity":1.0}]}
# drop matcher
# init simple matcher
=
# check is match
# True
# match as list
=
# [{"word_id":1,"word":"妳好&世界"},{"word_id":2,"word":"hello"}]
# drop simple matcher
Important Notes
- The extension_types.py is not required, you can use the dynamic library directly.
- Always call
drop_matcher,drop_simple_matcher, anddrop_stringafter initializing and processing to avoid memory leaks.