Midora/import-data.js

17 lines
585 B
JavaScript
Raw Normal View History

2018-09-16 12:20:54 +02:00
var bloomfilter = require("./extension/bloomfilter.js");
var fs = require('fs');
function importFile(txt, name) {
2019-05-12 17:29:43 +02:00
var b = new bloomfilter.BloomFilter(/*bits*/ 2300415, 20);
2018-09-16 12:20:54 +02:00
for (var line of fs.readFileSync(txt).toString().split('\n')) {
line = line.trim();
if (line) b.add(line);
}
var bucketsAsBytes = new Uint8Array(b.buckets.buffer);
fs.writeFileSync("extension/data/" + name + ".dat", new Buffer(bucketsAsBytes));
}
importFile("C:\\ML\\facebook\\transphobic.txt", "transphobic");
importFile("C:\\ML\\facebook\\t-friendly.txt", "t-friendly");