optimizer.js 628 B

1234567891011121314151617181920212223242526
  1. const readline = require('readline');
  2. const file = require('./src/file');
  3. const fs = file.fs;
  4. const path = './data/opti/';
  5. const source = './data/preprocess.ppf';
  6. let data = {};
  7. file.makedir(path);
  8. const reader = readline.createInterface({
  9. input: fs.createReadStream(source)
  10. });
  11. reader.on('line', (line) => {
  12. const group = JSON.parse(line);
  13. group.forEach(auth => {
  14. let coauth = JSON.parse(line);
  15. coauth.splice(coauth.indexOf(auth), 1);
  16. coauth.forEach(elt => {
  17. file.append(path + auth, elt + '\n');
  18. });
  19. });
  20. });
  21. reader.on('close', () => {
  22. console.log('Fin');
  23. });