UNPKG

@formant/ava

Version:

A framework for automated visual analytics.

55 lines (54 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); /* eslint-disable no-template-curly-in-string */ var ntv_1 = require("../../../ntv"); var base_1 = require("./base"); var variableMetaMap = { pcorr: { varType: 'metric_value', }, m1: { varType: 'metric_value', }, m2: { varType: 'metric_value', }, }; var CorrelationNarrativeStrategy = /** @class */ (function (_super) { tslib_1.__extends(CorrelationNarrativeStrategy, _super); function CorrelationNarrativeStrategy() { return _super !== null && _super.apply(this, arguments) || this; } CorrelationNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) { var patterns = insightInfo.patterns; var _a = patterns[0], _b = tslib_1.__read(_a.measures, 2), m1 = _b[0], m2 = _b[1], pcorr = _a.pcorr; var spec = (0, ntv_1.generateTextSpec)({ structures: CorrelationNarrativeStrategy.structures[lang], variable: { m1: m1, m2: m2, pcorr: pcorr, }, }); return spec.sections[0].paragraphs; }; CorrelationNarrativeStrategy.insightType = 'correlation'; CorrelationNarrativeStrategy.structures = { 'zh-CN': [ { template: '${m1} 与 ${m2} 相关性最大,相关系数为 ${pcorr}。', variableMetaMap: variableMetaMap, }, ], 'en-US': [ { template: " ${m1} and ${m2}, are highly correlated. Their relationship is measured by a number, ${pcorr}, which tells us just how closely they're linked. A higher number means they move in sync more often.", variableMetaMap: variableMetaMap, displayType: 'paragraph', }, ], }; return CorrelationNarrativeStrategy; }(base_1.InsightNarrativeStrategy)); exports.default = CorrelationNarrativeStrategy;