guess-rater
v1.5.0
Published
A flexible fuzzy matching and string normalization engine for JavaScript.
Maintainers
Readme
Guess‑Rater
Fuzzy string matching for JavaScript. Handles typos, word order, accents, and punctuation — with five algorithms, a normalization pipeline, and full TypeScript support.
Install
npm install guess-raterESM only. Requires "type": "module" in your package.json.
Usage
import { rate, isMatch, findBestMatch, filterMatches, extract, createMatcher } from 'guess-rater'
rate('Molière', 'moliere') // 100
rate('levenshtein', 'levenstein') // ~88
rate('John Smith', 'Smith John', { algorithm: 'tokenSort' }) // 100
isMatch('Saint-Nazaire', 'saint nazaire', 85) // true
findBestMatch('peugeot', ['Renault Clio', 'Peugeot 208', 'BMW'])
// { value: 'Peugeot 208', score: 82, index: 1 }
filterMatches('iPhone', ['iPhone 15', 'Samsung S24', 'iPhone 14'], { threshold: 70 })
// ['iPhone 15', 'iPhone 14']
extract('apple', ['Apple Watch', 'Apple TV', 'Samsung TV'], { limit: 2 })
// ['Apple Watch', 'Apple TV']Reuse a configuration with createMatcher():
const matcher = createMatcher({
algorithm: 'hybrid',
normalize: { removeAccents: true, sortTokens: true }
})
matcher.rate('Jean-Paul', 'jean paul') // 100
matcher.isMatch('Café de Paris', 'cafe de paris') // true
matcher.filterMatches('iphone', catalog)Documentation
tfoucher5.github.io/guess-rater
- Quickstart
- Algorithms — levenshtein, jaroWinkler, tokenSort, tokenSet, hybrid
- Normalization — accents, casing, stop words, replacements
- List helpers — rankCandidates, findBestMatch, filterMatches, extract
- API reference
License
MIT
