Skip to content

Commit

Permalink
Add fuzzysearch to comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
ts-thomas committed Feb 22, 2019
1 parent 8a4c8f8 commit 5196037
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ Get Latest (Stable Release):
<tr>
<td>flexsearch.min.js</td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.min.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.min.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.min.js</a></td>
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.min.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.min.js</a></td>
</tr>
<tr></tr>
<tr>
<td>flexsearch.light.js</td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.light.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.light.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.light.js</a></td>
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.light.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.light.js</a></td>
</tr>
<tr></tr>
<tr>
<td>flexsearch.compact.js</td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.compact.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.compact.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.compact.js</a></td>
<td><a href="https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.compact.js" target="_blank">https://rawcdn.githack.com/nextapps-de/flexsearch/8a4c8f849d8f78deed08e2d78c7400c27297deb6/dist/flexsearch.compact.js</a></td>
</tr>
<tr></tr>
<tr>
Expand Down
6 changes: 3 additions & 3 deletions flexsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3967,9 +3967,9 @@
"var SUPPORT_INFO = " + (SUPPORT_INFO ? "true" : "false") + ";" +
"var SUPPORT_DOCUMENT = " + (SUPPORT_DOCUMENT ? "true" : "false") + ";" +
"var SUPPORT_WHERE = " + (SUPPORT_WHERE ? "true" : "false") + ";" +
"var SUPPORT_WHERE = " + (SUPPORT_PAGINATION ? "true" : "false") + ";" +
"var SUPPORT_WHERE = " + (SUPPORT_OPERATOR ? "true" : "false") + ";" +
"var SUPPORT_WHERE = " + (SUPPORT_CALLBACK ? "true" : "false") + ";" +
"var SUPPORT_PAGINATION = " + (SUPPORT_PAGINATION ? "true" : "false") + ";" +
"var SUPPORT_OPERATOR = " + (SUPPORT_OPERATOR ? "true" : "false") + ";" +
"var SUPPORT_CALLBACK = " + (SUPPORT_CALLBACK ? "true" : "false") + ";" +
"var SUPPORT_WORKER = true;"

) + "(" + _worker.toString() + ")()"
Expand Down
18 changes: 17 additions & 1 deletion test/benchmark-short.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ <h4>Indexed Text: Movie Titles</h4>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/js-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/BitSet.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
<script src="https://gist.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
<script src="https://gistcdn.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
<script src="https://rawcdn.githack.com/jeancroy/FuzzySearch/cbcdd8307d70a209b1cbf17a535158d5c21840d7/dist/FuzzySearch.min.js"></script>
<script src="../data/movies.js"></script>
<script>

Expand All @@ -49,6 +50,7 @@ <h4>Indexed Text: Movie Titles</h4>
var jssearch;
var jsii;
var bm25;
var fuzzysearch;

var tests = {

Expand Down Expand Up @@ -333,6 +335,20 @@ <h4>Indexed Text: Movie Titles</h4>
return bm25.search(query);
},
loops: 50
},

fuzzysearch: {

init: function(){

fuzzysearch = new FuzzySearch({source:data.slice(0)});
},
add: function(index, content){},
query: function(query){

return fuzzysearch.search(query);
},
loops: 4
}
};

Expand Down
22 changes: 19 additions & 3 deletions test/benchmark.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/js-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/BitSet.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
<script src="https://gist.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
<script src="https://gistcdn.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
<script src="https://rawcdn.githack.com/jeancroy/FuzzySearch/cbcdd8307d70a209b1cbf17a535158d5c21840d7/dist/FuzzySearch.min.js"></script>
<script src="../data/gulliver.js"></script>
<script>

Expand All @@ -49,6 +50,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
var jssearch;
var jsii;
var bm25;
var fuzzysearch;

var tests = {

Expand Down Expand Up @@ -329,6 +331,20 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
return bm25.search(query);
},
loops: 95
},

fuzzysearch: {

init: function(){

fuzzysearch = new FuzzySearch({source:text_data.slice(0)});
},
add: function(index, content){},
query: function(query){

return fuzzysearch.search(query);
},
loops: 4
}
};

Expand Down Expand Up @@ -369,9 +385,9 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>

test.init();

if(is_mobile && (test.loops > 1)){
if(is_mobile){

test.loops = (test.loops / 5) >> 0;
test.loops = Math.max((test.loops / 5) >> 0, 1);
}

for(var i = 0; i < text_data.length; i++){
Expand Down
10 changes: 5 additions & 5 deletions test/matching-presets.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Presets Matching Test</title>
<title>Presets Scoring Comparison</title>
<style>
body{
font-family: sans-serif;
Expand All @@ -13,7 +13,7 @@
</style>
</head>
<body>
<h2>Presets Relevance Scoring Comparison</h2>
<h2>Presets Scoring Comparison</h2>
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<hr>
<script src="../dist/flexsearch.min.js"></script>
Expand All @@ -25,9 +25,9 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<th>default</th>
<th>memory</th>
<th>speed</th>
<th>matching</th>
<th>scoring</th>
<th>balanced</th>
<th>match</th>
<th>score</th>
<th>balance</th>
<th>fast</th>
</tr>
<tr id="test-1">
Expand Down
41 changes: 32 additions & 9 deletions test/matching.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<th>jssearch</th>
<th>jsii</th>
<th>bm25</th>
<th>fuzzysearch</th>
</tr>
<tr id="test-1">
<td style="width: 200px"></td>
Expand All @@ -41,6 +42,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-2">
<td></td>
Expand All @@ -53,6 +55,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-3">
<td></td>
Expand All @@ -65,6 +68,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-4">
<td></td>
Expand All @@ -77,6 +81,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-5">
<td></td>
Expand All @@ -89,6 +94,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-6">
<td></td>
Expand All @@ -101,6 +107,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-7">
<td></td>
Expand All @@ -113,6 +120,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-8">
<td></td>
Expand All @@ -125,6 +133,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-9">
<td></td>
Expand All @@ -137,6 +146,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-10">
<td></td>
Expand All @@ -149,6 +159,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-11">
<td></td>
Expand All @@ -161,6 +172,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-12">
<td></td>
Expand All @@ -173,6 +185,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr>
<td colspan="10">
Expand All @@ -191,6 +204,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
</table>
</div>
Expand All @@ -210,7 +224,8 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/js-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/BitSet.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
<script src="https://gist.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
<script src="https://gistcdn.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
<script src="https://rawcdn.githack.com/jeancroy/FuzzySearch/cbcdd8307d70a209b1cbf17a535158d5c21840d7/dist/FuzzySearch.min.js"></script>
<script src="../data/gulliver.js"></script>
<script>

Expand Down Expand Up @@ -254,6 +269,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
var jssearch;
var jsii;
var bm25;
var fuzzysearch;

// -----------------------------------------------------------

Expand All @@ -274,14 +290,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>

// -----------------------------------------------------------

flexsearch = new FlexSearch({
encode: 'extra',
tokenize: 'strict',
threshold: 0,
resolution: 9,
depth: 3,
suggest: true
});
flexsearch = new FlexSearch("score");

console.time('flexsearch');

Expand Down Expand Up @@ -401,6 +410,12 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>

// -----------------------------------------------------------

console.time('fuzzysearch');
fuzzysearch = new FuzzySearch({source:data.slice(0)});
console.timeEnd('fuzzysearch');

// -----------------------------------------------------------

do_test('test-1', 'without breach of modesty', [493]);
do_test('test-2', 'went softly stream', [446]);
do_test('test-3', 'princes of the ambition', [72, 408]);
Expand Down Expand Up @@ -464,6 +479,14 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
case 9:
results = bm25.search(query).map(function(val){return val.id});
break;

case 10:
results = fuzzysearch.search(query).map(function(val){
for(var i = 0; i < data.length; i++){
if(val === data[i]) return i;
}
});
break;
}

for(var a = 0; a < ref.length; a++){
Expand Down

0 comments on commit 5196037

Please sign in to comment.