How fuzzyset performs searches
masterThe fuzzyset search process follows these steps:
- Normalization: The input string is normalized by removing non-word characters (except spaces and commas) and converting to lowercase.
- N-gram Generation: The string is broken into n-grams based on the
gram_size_lowerandgram_size_upperparameters. - Reverse Index Lookup: The engine performs a dictionary lookup on the n-grams to find candidate elements in the set.
- Scoring:
- It first attempts to match using the largest n-grams (
gram_size_upper). - For candidates, it computes cosine similarity.
- If
use_levenshteinisTrue, it truncates the search space to the top 50 candidates and computes a score based on Levenshtein distance to better handle transpositions. - If no matches are found with the upper gram size, it repeats the process using the lower gram size (e.g., bigrams).
- It first attempts to match using the largest n-grams (