@formant/ava
Version:
A framework for automated visual analytics.
19 lines (18 loc) • 901 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var factory_1 = tslib_1.__importDefault(require("./factory"));
function isHomogeneousPattern(insightInfo) {
return 'childPatterns' in insightInfo;
}
function generateInsightNarrative(insightInfo, options) {
var _a;
var insightType = isHomogeneousPattern(insightInfo) ? insightInfo === null || insightInfo === void 0 ? void 0 : insightInfo.type : (_a = insightInfo === null || insightInfo === void 0 ? void 0 : insightInfo.patterns[0]) === null || _a === void 0 ? void 0 : _a.type;
if (!insightType)
throw Error('insight info has no insight type');
var lang = options.lang;
var strategy = factory_1.default.getStrategy(insightType);
var result = strategy.generateTextSpec(insightInfo, lang);
return result;
}
exports.default = generateInsightNarrative;