Crates.io | magic_string_search |
lib.rs | magic_string_search |
version | 0.2.1 |
source | src |
created_at | 2024-03-27 15:52:37.072064 |
updated_at | 2024-07-08 15:35:39.445214 |
description | A simple string search library to rank strings based on their similarity to a query string. |
homepage | |
repository | https://github.com/DeForestt/string_search |
max_upload_size | |
id | 1188135 |
size | 1,312,848 |
Magic String Search is a simple yet powerful Rust library designed to find and rank strings based on their similarity to a query string. Whether you're developing a search engine, implementing auto-suggestion functionality, or just need to sort a list of strings by relevance, Magic String Search provides a straightforward API to accomplish these tasks efficiently.
Add Magic String Search to your Cargo.toml
file:
[dependencies]
magic_string_search = "0.1.5"
Below is a simple example on how to use Magic String Search to compare two strings and rank multiple strings based on their similarity to a query string:
use magic_string_search::{compare, rank};
fn main() {
// Compare two strings
let similarity_score = compare("Hello, world!", "Hello, Rust!");
println!("Similarity score: {}", similarity_score);
// Rank strings by similarity
let subjects = vec!["Hello, world!", "Hello, Rust!", "Goodbye, world!"];
let ranked = rank("Hello, Rust!", subjects);
for (score, subject) in ranked {
println!("{} - {}", score, subject);
}
}
Contributions to Magic String Search are welcome! Whether it's bug reports, feature requests, or code contributions, please feel free to open an issue or a pull request on our GitHub repository.
Magic String Search is released under the MIT License. See the LICENSE file for more details.