-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaverage.js
More file actions
31 lines (28 loc) · 896 Bytes
/
average.js
File metadata and controls
31 lines (28 loc) · 896 Bytes
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
const RandExp = require("randexp");
const fs = require("fs");
const RandomChecker = require(".");
(async () => {
let rc = new RandomChecker();
let wordlist = fs.readFileSync('wordlist', 'utf-8').trim().split(' ');
let randex = new RandExp(/[a-z]{10}/);
let totalHuman = 0;
let totalRobot = 0;
const max = 50000;
for (let i = 0; i < max; i++) {
let text = wordlist[i];
let human = await rc.check(text);
totalHuman += human;
let random = randex.gen();
let robot = await rc.check(random);
totalRobot += robot;
}
console.log(`Total:`);
console.log(' Human:', totalHuman);
console.log(' Robot:', totalRobot);
console.log('Optimal Index:', (totalHuman + totalRobot) / 100000);
})();
function sleep(ms) {
return new Promise(async (resolve, reject) => {
setTimeout(resolve, ms);
});
}