https://github.com/holsee/spirit_fingers
Elixir SimHash NIFs written in Rust
https://github.com/holsee/spirit_fingers
elixir nif rust simhash
Last synced: about 2 months ago
JSON representation
Elixir SimHash NIFs written in Rust
- Host: GitHub
- URL: https://github.com/holsee/spirit_fingers
- Owner: holsee
- License: mit
- Created: 2018-05-16T14:53:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T00:08:35.000Z (almost 3 years ago)
- Last Synced: 2025-08-11T01:31:15.662Z (4 months ago)
- Topics: elixir, nif, rust, simhash
- Language: Elixir
- Homepage: https://hex.pm/packages/spirit_fingers
- Size: 3.36 MB
- Stars: 19
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SpiritFingers
"Fast SimHash NIFs written in Rust 🐇💨 as Erlang/Elixir versions were too slow 🐢"
For a full comparison versus native elixir solutions see: [Simhash Benchmarks](https://github.com/holsee/simhash_benchmarks)
TL;DR Spirit Fingers is 400-900x faster, orders of magnitude more memory efficient and handles large binaries where others cannot.

* [Hex Package](https://hex.pm/packages/spirit_fingers).
* [Documentation](https://hexdocs.pm/spirit_fingers).
## Build
```
mix compile
```
## Test
```
mix test
```
## Versions
* Elixir ~> 1.14
* OTP 25
* Rust 2021 ~> 1.67.0
* Rustler 0.27.0
## Installation
Add `spirit_fingers` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:spirit_fingers, "~> 0.4"}
]
end
```
## Usage
Generate SimHash:
``` elixir
SpiritFingers.SimHash.similarity_hash("wow")
{:ok, 17399923637769257768}
```
Similarity between strings:
``` elixir
SpiritFingers.SimHash.similarity("Hocus pocus", "Hocus pocus pilatus pas")
{:ok, 0.9375}
```
Hamming Distance between hashes:
``` elixir
SpiritFingers.SimHash.hamming_distance(17399923637769257768, 17399923637769257768)
{:ok, 0.0}
```
Similarity between hashes:
``` elixir
SpiritFingers.SimHash.hash_similarity(17399923637769257768, 17399923637769257768)
{:ok, 1.0}
```