diff options
author | Keating950 <keating.reid@protonmail.com> | 2021-08-17 03:40:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-17 16:40:24 +0900 |
commit | 3f90fb42d8871920138ace9878502f22a4d91e85 (patch) | |
tree | f687f20011a7b18a457e5e26b09eed4989b54604 /src/algo | |
parent | 9bd8988300d3576d58bc1c76c2e8736db37ba3e3 (diff) |
Fix spelling error (Extention -> Extension) (#2589)
Diffstat (limited to 'src/algo')
-rw-r--r-- | src/algo/algo.go | 14 | ||||
-rw-r--r-- | src/algo/algo_test.go | 22 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/algo/algo.go b/src/algo/algo.go index b3f29e66..40fb2af6 100644 --- a/src/algo/algo.go +++ b/src/algo/algo.go @@ -107,7 +107,7 @@ type Result struct { const ( scoreMatch = 16 scoreGapStart = -3 - scoreGapExtention = -1 + scoreGapExtension = -1 // We prefer matches at the beginning of a word, but the bonus should not be // too great to prevent the longer acronym matches from always winning over @@ -125,16 +125,16 @@ const ( // Edge-triggered bonus for matches in camelCase words. // Compared to word-boundary case, they don't accompany single-character gaps // (e.g. FooBar vs. foo-bar), so we deduct bonus point accordingly. - bonusCamel123 = bonusBoundary + scoreGapExtention + bonusCamel123 = bonusBoundary + scoreGapExtension // Minimum bonus point given to characters in consecutive chunks. // Note that bonus points for consecutive matches shouldn't have needed if we // used fixed match score as in the original algorithm. - bonusConsecutive = -(scoreGapStart + scoreGapExtention) + bonusConsecutive = -(scoreGapStart + scoreGapExtension) // The first character in the typed pattern usually has more significance // than the rest so it's important that it appears at special positions where - // bonus points are given. e.g. "to-go" vs. "ongoing" on "og" or on "ogo". + // bonus points are given, e.g. "to-go" vs. "ongoing" on "og" or on "ogo". // The amount of the extra bonus should be limited so that the gap penalty is // still respected. bonusFirstCharMultiplier = 2 @@ -424,7 +424,7 @@ func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util. inGap = false } else { if inGap { - H0sub[off] = util.Max16(prevH0+scoreGapExtention, 0) + H0sub[off] = util.Max16(prevH0+scoreGapExtension, 0) } else { H0sub[off] = util.Max16(prevH0+scoreGapStart, 0) } @@ -477,7 +477,7 @@ func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util. var s1, s2, consecutive int16 if inGap { - s2 = Hleft[off] + scoreGapExtention + s2 = Hleft[off] + scoreGapExtension } else { s2 = Hleft[off] + scoreGapStart } @@ -598,7 +598,7 @@ func calculateScore(caseSensitive bool, normalize bool, text *util.Chars, patter pidx++ } else { if inGap { - score += scoreGapExtention + score += scoreGapExtension } else { score += scoreGapStart } diff --git a/src/algo/algo_test.go b/src/algo/algo_test.go index d8f40cdf..218ca1f1 100644 --- a/src/algo/algo_test.go +++ b/src/algo/algo_test.go @@ -43,10 +43,10 @@ func TestFuzzyMatch(t *testing.T) { for _, fn := range []Algo{FuzzyMatchV1, FuzzyMatchV2} { for _, forward := range []bool{true, false} { assertMatch(t, fn, false, forward, "fooBarbaz1", "oBZ", 2, 9, - scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtention*3) + scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtension*3) assertMatch(t, fn, false, forward, "foo bar baz", "fbb", 0, 9, scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+ - bonusBoundary*2+2*scoreGapStart+4*scoreGapExtention) + bonusBoundary*2+2*scoreGapStart+4*scoreGapExtension) assertMatch(t, fn, false, forward, "/AutomatorDocument.icns", "rdoc", 9, 13, scoreMatch*4+bonusCamel123+bonusConsecutive*2) assertMatch(t, fn, false, forward, "/man1/zshcompctl.1", "zshc", 6, 10, @@ -54,18 +54,18 @@ func TestFuzzyMatch(t *testing.T) { assertMatch(t, fn, false, forward, "/.oh-my-zsh/cache", "zshc", 8, 13, scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*3+scoreGapStart) assertMatch(t, fn, false, forward, "ab0123 456", "12356", 3, 10, - scoreMatch*5+bonusConsecutive*3+scoreGapStart+scoreGapExtention) + scoreMatch*5+bonusConsecutive*3+scoreGapStart+scoreGapExtension) assertMatch(t, fn, false, forward, "abc123 456", "12356", 3, 10, - scoreMatch*5+bonusCamel123*bonusFirstCharMultiplier+bonusCamel123*2+bonusConsecutive+scoreGapStart+scoreGapExtention) + scoreMatch*5+bonusCamel123*bonusFirstCharMultiplier+bonusCamel123*2+bonusConsecutive+scoreGapStart+scoreGapExtension) assertMatch(t, fn, false, forward, "foo/bar/baz", "fbb", 0, 9, scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+ - bonusBoundary*2+2*scoreGapStart+4*scoreGapExtention) + bonusBoundary*2+2*scoreGapStart+4*scoreGapExtension) assertMatch(t, fn, false, forward, "fooBarBaz", "fbb", 0, 7, scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+ - bonusCamel123*2+2*scoreGapStart+2*scoreGapExtention) + bonusCamel123*2+2*scoreGapStart+2*scoreGapExtension) assertMatch(t, fn, false, forward, "foo barbaz", "fbb", 0, 8, scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary+ - scoreGapStart*2+scoreGapExtention*3) + scoreGapStart*2+scoreGapExtension*3) assertMatch(t, fn, false, forward, "fooBar Baz", "foob", 0, 4, scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*3) assertMatch(t, fn, false, forward, "xFoo-Bar Baz", "foo-b", 1, 6, @@ -73,13 +73,13 @@ func TestFuzzyMatch(t *testing.T) { bonusNonWord+bonusBoundary) assertMatch(t, fn, true, forward, "fooBarbaz", "oBz", 2, 9, - scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtention*3) + scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtension*3) assertMatch(t, fn, true, forward, "Foo/Bar/Baz", "FBB", 0, 9, scoreMatch*3+bonusBoundary*(bonusFirstCharMultiplier+2)+ - scoreGapStart*2+scoreGapExtention*4) + scoreGapStart*2+scoreGapExtension*4) assertMatch(t, fn, true, forward, "FooBarBaz", "FBB", 0, 7, scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+bonusCamel123*2+ - scoreGapStart*2+scoreGapExtention*2) + scoreGapStart*2+scoreGapExtension*2) assertMatch(t, fn, true, forward, "FooBar Baz", "FooB", 0, 4, scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*2+ util.Max(bonusCamel123, bonusBoundary)) @@ -99,7 +99,7 @@ func TestFuzzyMatch(t *testing.T) { func TestFuzzyMatchBackward(t *testing.T) { assertMatch(t, FuzzyMatchV1, false, true, "foobar fb", "fb", 0, 4, scoreMatch*2+bonusBoundary*bonusFirstCharMultiplier+ - scoreGapStart+scoreGapExtention) + scoreGapStart+scoreGapExtension) assertMatch(t, FuzzyMatchV1, false, false, "foobar fb", "fb", 7, 9, scoreMatch*2+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary) } |