Skip to content

Commit 8ddbf06

Browse files
committed
v.1.1.0
* Fuzzy Matcher
1 parent a8e6cfa commit 8ddbf06

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ uses [Matchy](https://github.com/foo123/Matchy)
1616
* [Commentz-Walter Matcher](https://en.wikipedia.org/wiki/Commentz-Walter_algorithm) (TODO)
1717
* [Baeza-Yates-Gonnet Matcher](https://en.wikipedia.org/wiki/Bitap_algorithm) (TODO)
1818
* [Aho-Corasick Matcher](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm) (TODO)
19+
* Fuzzy Matcher
1920

2021
[![screenshot](/screenshot.png)](https://foo123.github.io/examples/pattern-matching-algorithms/)
2122

src/Pattern.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
*
33
* Pattern.js
4-
* @version: 1.0.0
4+
* @version: 1.1.0
55
*
66
* Pattern Matching Algorithms Tests in JavaScript
77
* https://github.com/foo123/PatternMatchingAlgorithms
@@ -21,7 +21,7 @@ else if (!(name in root)) /* Browser/WebWorker/.. */
2121
"use strict";
2222

2323
// http://en.wikipedia.org/wiki/String_searching_algorithm
24-
var Pattern = {VERSION: "1.0.0"}, Matchy;
24+
var Pattern = {VERSION: "1.1.0"}, Matchy;
2525

2626
Pattern.Matchy = function(MatchyRef) {
2727
Matchy = MatchyRef;
@@ -39,17 +39,18 @@ Pattern.Matcher.prototype = {
3939
description: '',
4040
_pattern: null,
4141
_matcher: null,
42-
_err: 0,
42+
_errors: 0,
4343

4444
dispose: function() {
4545
this._pattern = null;
4646
this._matcher = null;
4747
return this;
4848
},
4949

50-
pattern: function(pattern) {
50+
pattern: function(pattern, errors) {
5151
this._pattern = pattern || null;
5252
this._matcher = this._pattern ? ("function" === typeof this.algorithm ? this.algorithm.bind(this) : (new Matchy())[this.algorithm](this._pattern)) : null;
53+
this._errors = errors || 0;
5354
return this;
5455
},
5556

@@ -82,7 +83,7 @@ Pattern.FuzzyMatcher = new Pattern.Matcher(function fuzzy_matcher(s, o) {
8283
if (o < 0) o += n;
8384
if ((0 < n) && (0 < m) && (n >= o+m))
8485
{
85-
return (new Matchy.NFA(p, {errors:this._err || 1})).match(s, o);
86+
return (new Matchy.NFA(p, {errors:this._errors || 0})).match(s, o);
8687
}
8788
return -1;
8889
},

src/Pattern.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)