-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnode-test.js
31 lines (28 loc) · 998 Bytes
/
node-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* ********************************************************************
* fts_fuzzy_match tester, by Tristano Ajmone, public domain (CC0 1.0).
* https://github.com/tajmone/fuzzy-search
* ********************************************************************
*/
const datasetFile = '../../../dataset/ue4_filenames.txt';
const resultsFile = './test_results.txt';
const pattern = 'LLL';
const maxMatches = 100;
const fs = require('fs');
eval(fs.readFileSync('./fts_fuzzy_match.js')+'');
const outFile = fs.createWriteStream(resultsFile);
try {
const dataset = fs.readFileSync(datasetFile, 'UTF-8');
const lines = dataset.split(/\r?\n/);
let cnt = matches = 0;
while (matches < maxMatches && cnt < lines.length) {
let matchRes = fuzzy_match(pattern, lines[cnt]);
if (matchRes[0]) {
outFile.write(matchRes[1] + "|" + lines[cnt] + '\n');
matches += 1;
}
cnt += 1;
}
} catch (err) {
console.error(err);
}
outFile.end();