#string-similarity #string-search #query-string #search-engine #comparison #search-algorithms #normalized

magic_string_search

A simple string search library to rank strings based on their similarity to a query string

6 releases

0.2.1 Jul 8, 2024
0.2.0 Apr 18, 2024
0.1.5 Mar 27, 2024

#1 in #normalized


Used in my-notes

MIT license

1MB
235 lines

Contains (WOFF font, 400KB) NanumBarunGothic-0f09457c7a19b7c6.ttf.woff2, (WOFF font, 135KB) FiraSans-Medium-8f9a781e4970d388.woff2, (WOFF font, 130KB) FiraSans-Regular-018c141bf0843ffd.woff2, (WOFF font, 82KB) SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2, (WOFF font, 77KB) SourceSerif4-Regular-46f98efaafac5295.ttf.woff2, (WOFF font, 45KB) SourceCodePro-It-1cc31594bf4f1f79.ttf.woff2 and 3 more.

Magic String Search

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.

Features

  • String Similarity Ranking: Compare and rank strings based on their similarity to a given query string.
  • Longest Common Subsequence (LCS): Utilizes the LCS algorithm to assess the similarity between strings.
  • Normalized Comparison: Offers a normalized comparison function to handle varying lengths of strings and queries.

Installation

Add Magic String Search to your Cargo.toml file:

[dependencies]
magic_string_search = "0.1.5"

Usage

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);
    }
}

Contributing

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.

License

Magic String Search is released under the MIT License. See the LICENSE file for more details.

No runtime deps