-
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
||
|
@@ -49,6 +50,7 @@ <h4>Indexed Text: Movie Titles</h4> | |
var jssearch; | ||
var jsii; | ||
var bm25; | ||
var fuzzysearch; | ||
|
||
var tests = { | ||
|
||
|
@@ -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 | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
||
|
@@ -49,6 +50,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4> | |
var jssearch; | ||
var jsii; | ||
var bm25; | ||
var fuzzysearch; | ||
|
||
var tests = { | ||
|
||
|
@@ -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 | ||
} | ||
}; | ||
|
||
|
@@ -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++){ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
@@ -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"> | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
||
|
@@ -254,6 +269,7 @@ <h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4> | |
var jssearch; | ||
var jsii; | ||
var bm25; | ||
var fuzzysearch; | ||
|
||
// ----------------------------------------------------------- | ||
|
||
|
@@ -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'); | ||
|
||
|
@@ -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]); | ||
|
@@ -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++){ | ||
|