StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.4 KiB
66 lines
1.4 KiB
'use strict';
|
|
|
|
var through = require('through2');
|
|
var extend = require('extend-shallow');
|
|
var Questions = require('question-cache');
|
|
|
|
module.exports = function(options) {
|
|
var opts = extend({key: 'relative', save: false}, options);
|
|
var msg = opts.message || 'Which files do you want to write?';
|
|
var questions = new Questions();
|
|
var paths = [];
|
|
var files = {};
|
|
|
|
return through.obj(function(file, enc, next) {
|
|
if (opts.skip) {
|
|
next(null, file);
|
|
return;
|
|
}
|
|
|
|
var key = fileKey(file, opts);
|
|
paths.push(key);
|
|
files[key] = file;
|
|
next();
|
|
}, function(next) {
|
|
var stream = this;
|
|
|
|
if (typeof opts.choices === 'string') {
|
|
opts.choices = [opts.choices];
|
|
}
|
|
|
|
if (Array.isArray(opts.choices)) {
|
|
opts.choices.forEach(function(filepath) {
|
|
stream.push(files[filepath]);
|
|
});
|
|
next();
|
|
return;
|
|
}
|
|
|
|
if (paths.length === 0) {
|
|
next();
|
|
return;
|
|
}
|
|
|
|
questions.choices('files', msg, paths);
|
|
questions.ask('files', opts, function(err, answers) {
|
|
if (err || !answers.files) {
|
|
next(err);
|
|
return;
|
|
}
|
|
answers.files.forEach(function(filepath) {
|
|
stream.push(files[filepath]);
|
|
});
|
|
next();
|
|
});
|
|
});
|
|
};
|
|
|
|
function fileKey(file, opts) {
|
|
if (typeof opts.key === 'string') {
|
|
return file[opts.key];
|
|
}
|
|
if (typeof opts.key === 'function') {
|
|
return opts.key(file);
|
|
}
|
|
return file.relative;
|
|
}
|
|
|