26 lines
514 B
JavaScript
26 lines
514 B
JavaScript
const _ = require("lodash");
|
|
const { Guesstimator } = require('@foretold/guesstimator/src');
|
|
|
|
const stringToSamples = (
|
|
text,
|
|
sampleCount,
|
|
inputs = [],
|
|
) => {
|
|
const [_error, { parsedInput, parsedError }] = Guesstimator.parse({ text:"=" + text });
|
|
|
|
const guesstimator = new Guesstimator({ parsedInput });
|
|
const {values, errors} = guesstimator.sample(
|
|
sampleCount,
|
|
inputs,
|
|
);
|
|
if (errors.length > 0){
|
|
return []
|
|
} else {
|
|
return values
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
stringToSamples,
|
|
};
|