Skip to content

Commit

Permalink
Version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
krisk committed Feb 5, 2016
2 parents 89131d4 + 69bbbce commit 6b63734
Show file tree
Hide file tree
Showing 10 changed files with 982 additions and 704 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ test/index.html
latest.zip
.DS_Store
.idea
runner.js
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Version 2.0.0

- Modified search algorithm to search individual words AND the full string, computing the final score as a function of both. This yields better scoring accuracy (#41)
- Changed exact substrings to not have a score of zero. That is searching for "hell" in "hello" will not yield a score of zero, while searching for "hello" will (#63)
- Added `verbose` option, which will print to the console useful information, mostly for debugging
- Improved code structure.
- Added version information within Fuse itself
- Added this Changelog (#64)
- Added fallback when pattern length is greater than machine word length (i.e, > 32 characters) (#38)
- Allowed results with a value of 0 to be returned (#73)
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
*Update: There are plenty of enhancements that need to be done to this library. There's more work than available time for me; so if you're interested in being one of the core contributors and helping out, let's talk!*

Fuse
====
# Fuse

[![NPM](https://nodei.co/npm/fuse.js.png?downloads=true)](https://nodei.co/npm/fuse.js/)

Expand Down Expand Up @@ -98,7 +95,7 @@ getFn: function (obj, path) {

The function that is used for sorting the result list.

### Bitap specific options
---

**location** (*type*: `Integer`, *default*: `0`)

Expand All @@ -114,30 +111,44 @@ At what point does the match algorithm give up. A threshold of `0.0` requires a

**distance** (*type*: `Integer`, *default*: `100`)

Determines how close the match must be to the fuzzy location (specified by `location`). An exact letter match which is `distance` characters away from the fuzzy location would score as a complete mismatch. A `distance` of `0` requires the match be at the exact `location` specified, a `threshold` of `1000` would require a perfect match to be within 800 characters of the `location` to be found using a `threshold` of `0.8`.
Determines how close the match must be to the fuzzy location (specified by `location`). An exact letter match which is `distance` characters away from the fuzzy location would score as a complete mismatch. A `distance` of `0` requires the match be at the exact `location` specified, a `distance` of `1000` would require a perfect match to be within 800 characters of the `location` to be found using a `threshold` of `0.8`.

---

**maxPatternLength** (*type*: `Integer`, *default*: `32`)

The maximum length of the pattern. The longer the pattern, the more intensive the search operation will be. Whenever the pattern exceeds the `maxPatternLength`, an error will be thrown. Why is this important? Read [this](http://en.wikipedia.org/wiki/Word_(computer_architecture)#Word_size_choice).

---

**verbose** (*type*: `Boolean`, *default*: `false`)

Will print to the console. Useful for debugging.

## Methods

**search(pattern)**
**`search(/*pattern*/)`**

@param {String} pattern The pattern string to fuzzy search on.
@return {Array} A list of all serch matches.
```javascript
@param {String} pattern The pattern string to fuzzy search on.
@return {Array} A list of all search matches.
```

Searches for all the items whose keys (fuzzy) match the pattern.

**set(list)**
**`set(/*list*/)`**

@param {Array} list
@return {Array} The newly set list
```javascript
@param {Array} list
@return {Array} The newly set list
```

Sets a new list for Fuse to match against.

## Coding conventions

Code should be run through [Standard Format](https://www.npmjs.com/package/standard-format).

## Contributing to Fuse

Before submitting a pull request, please add relevant tests in `test/fuse-test.js`, and execute them via `npm test`.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fuse.js",
"version": "1.3.1",
"version": "2.0.0",
"main": "./src/fuse.js",
"ignore": [
"test"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fuse.js",
"author": "Kirollos Risk",
"version": "1.3.1",
"version": "2.0.0",
"description": "Lightweight fuzzy-search",
"license": "Apache",
"main": "./src/fuse.js",
Expand All @@ -15,4 +15,4 @@
"grunt-bump": "0.0.11",
"uglify-js": "*"
}
}
}
20 changes: 20 additions & 0 deletions runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Fuse = require('./src/fuse')

var items = [
// 'Borwaila hamlet',
// 'Bobe hamlet',
'Boma',
'Bo']
var fuse = new Fuse(items, {
include: ['score'],
verbose: true
})
var result = fuse.search('Bosdflkj sdlkfjs dlkfjsdlkfjsldkfj sldkfj slkdjflksdjflksdjf lkdsjf lksjdf lksjdflkjsd lkfj ')

// var items = ['FH Mannheim', 'University Mannheim']
// var fuse = new Fuse(items, {
// verbose: true
// })
// var result = fuse.search('Uni Mannheim')

return
Loading

0 comments on commit 6b63734

Please sign in to comment.