Skip to content

Commit

Permalink
Allow passing custom uFuzzy options. Add guide how to fix uFuzzy for …
Browse files Browse the repository at this point in the history
…CJK chars (#91)

Thanks to c0001 for providing original idea in PR #90

Co-authored-by: Simon Heimler <[email protected]>
  • Loading branch information
Fannon and Simon Heimler authored Mar 29, 2023
1 parent e2a1f2c commit 3f1764f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ customSearchEngines:
blank: https://www.npmjs.com
```
In case of making multilingual searching (CJK) correctly, you may need to tweak [uFuzzy](https://github.com/leeoniya/uFuzzy) options via option `ufuzzyOptions`, for example:

```yaml
# make CJK chars work for fuzzy search
uFuzzyOptions:
interSplit: (p{Unified_Ideograph=yes})+
```

## Scoring System

The scoring systems works roughly the following:
Expand Down
13 changes: 13 additions & 0 deletions popup/js/model/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,19 @@ export const defaultOptions = {
*/
scoreDateAddedBonusScorePerDay: 0.1,
scoreDateAddedBonusScoreMaximum: 5,

//////////////////////////////////////////
// POWER USER OPTIONS //
//////////////////////////////////////////

// Those are only meant for power users who know what they're doing
// And those options may also not be long-time stable

/**
* Customized options for the fuzzy search library uFuzzy ('@leeoniya/ufuzzy')
* @see https://github.com/leeoniya/uFuzzy/blob/main/src/uFuzzy.js#L9
*/
uFuzzyOptions: {},
}

/**
Expand Down
2 changes: 1 addition & 1 deletion popup/js/search/fuzzySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function fuzzySearchWithScoring(searchTerm, searchMode) {
const options = {
// How many characters "in between" are allowed -> increased fuzzyness
intraIns: Math.round(ext.opts.searchFuzzyness * 4.2),
interSplit: '(p{Unified_Ideograph=yes})+',
...(ext.opts.uFuzzyOptions || {}),
}

// When searchFuzzyness is set to 0.8 or higher:
Expand Down

0 comments on commit 3f1764f

Please sign in to comment.