@formant/ava 3.4.1-formant
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/dist/ava.min.js +1 -0
- package/esm/advisor/advise-pipeline/advicesForChart.js +68 -0
- package/esm/advisor/advise-pipeline/data-to-advices.js +241 -0
- package/esm/advisor/advise-pipeline/index.js +1 -0
- package/esm/advisor/advise-pipeline/spec-mapping.js +500 -0
- package/esm/advisor/advisor.js +35 -0
- package/esm/advisor/constants.js +13 -0
- package/esm/advisor/index.js +2 -0
- package/esm/advisor/lint-pipeline/check-rules.js +43 -0
- package/esm/advisor/lint-pipeline/getChartType.js +109 -0
- package/esm/advisor/lint-pipeline/index.js +0 -0
- package/esm/advisor/lint-pipeline/lintRules.js +32 -0
- package/esm/advisor/ruler/index.js +74 -0
- package/esm/advisor/ruler/rules/aggregation-single-row.js +21 -0
- package/esm/advisor/ruler/rules/all-can-be-table.js +17 -0
- package/esm/advisor/ruler/rules/bar-series-qty.js +36 -0
- package/esm/advisor/ruler/rules/bar-without-axis-min.js +41 -0
- package/esm/advisor/ruler/rules/constants.js +6 -0
- package/esm/advisor/ruler/rules/data-check.js +40 -0
- package/esm/advisor/ruler/rules/data-field-qty.js +26 -0
- package/esm/advisor/ruler/rules/diff-pie-sector.js +33 -0
- package/esm/advisor/ruler/rules/index.js +68 -0
- package/esm/advisor/ruler/rules/landscape-or-portrait.js +40 -0
- package/esm/advisor/ruler/rules/limit-series.js +47 -0
- package/esm/advisor/ruler/rules/line-field-time-ordinal.js +25 -0
- package/esm/advisor/ruler/rules/no-redundant-field.js +32 -0
- package/esm/advisor/ruler/rules/nominal-enum-combinatorial.js +54 -0
- package/esm/advisor/ruler/rules/purpose-check.js +27 -0
- package/esm/advisor/ruler/rules/series-qty-limit.js +34 -0
- package/esm/advisor/ruler/rules/x-axis-line-fading.js +41 -0
- package/esm/advisor/ruler/types.js +1 -0
- package/esm/advisor/ruler/utils.js +54 -0
- package/esm/advisor/types.js +1 -0
- package/esm/advisor/utils/clone.js +32 -0
- package/esm/advisor/utils/compare.js +14 -0
- package/esm/advisor/utils/computeScore.js +25 -0
- package/esm/advisor/utils/deep-mix.js +76 -0
- package/esm/advisor/utils/hasSubset.js +3 -0
- package/esm/advisor/utils/index.js +8 -0
- package/esm/advisor/utils/inferDataType.js +70 -0
- package/esm/advisor/utils/intersects.js +3 -0
- package/esm/advisor/utils/isNil.js +4 -0
- package/esm/ckb/base.js +1310 -0
- package/esm/ckb/ckb.js +55 -0
- package/esm/ckb/constants.js +197 -0
- package/esm/ckb/i18n/index.js +23 -0
- package/esm/ckb/i18n/types.js +1 -0
- package/esm/ckb/i18n/zh-CN.js +525 -0
- package/esm/ckb/index.js +14 -0
- package/esm/ckb/types.js +1 -0
- package/esm/common/types.js +1 -0
- package/esm/data/analysis/field/index.js +336 -0
- package/esm/data/analysis/field/types.js +1 -0
- package/esm/data/analysis/graph/index.js +170 -0
- package/esm/data/analysis/graph/types.js +1 -0
- package/esm/data/analysis/index.js +1 -0
- package/esm/data/analysis/types.js +1 -0
- package/esm/data/dataset/field/baseFrame.js +76 -0
- package/esm/data/dataset/field/dataFrame.js +556 -0
- package/esm/data/dataset/field/index.js +3 -0
- package/esm/data/dataset/field/series.js +149 -0
- package/esm/data/dataset/field/types.js +1 -0
- package/esm/data/dataset/field/utils.js +58 -0
- package/esm/data/dataset/graph/index.js +186 -0
- package/esm/data/dataset/graph/types.js +1 -0
- package/esm/data/dataset/graph/utils.js +15 -0
- package/esm/data/dataset/index.js +1 -0
- package/esm/data/dataset/types.js +1 -0
- package/esm/data/index.js +5 -0
- package/esm/data/statistics/IQR.js +49 -0
- package/esm/data/statistics/base.js +248 -0
- package/esm/data/statistics/bayesian.js +25 -0
- package/esm/data/statistics/buishand-u.js +19 -0
- package/esm/data/statistics/caches.js +28 -0
- package/esm/data/statistics/cdf.js +25 -0
- package/esm/data/statistics/constants.js +12 -0
- package/esm/data/statistics/index.js +7 -0
- package/esm/data/statistics/lowess.js +80 -0
- package/esm/data/statistics/mannkendall-test.js +50 -0
- package/esm/data/statistics/maxabs.js +9 -0
- package/esm/data/statistics/pcorrtest.js +76 -0
- package/esm/data/statistics/pettitt-test.js +33 -0
- package/esm/data/statistics/quantile.js +56 -0
- package/esm/data/statistics/types.js +1 -0
- package/esm/data/statistics/vector.js +67 -0
- package/esm/data/statistics/window.js +55 -0
- package/esm/data/types.js +2 -0
- package/esm/data/utils/common.js +58 -0
- package/esm/data/utils/index.js +5 -0
- package/esm/data/utils/isType/constants.js +24 -0
- package/esm/data/utils/isType/index.js +2 -0
- package/esm/data/utils/isType/isDateString.js +104 -0
- package/esm/data/utils/isType/isType.js +78 -0
- package/esm/index.js +11 -0
- package/esm/insight/algorithms/base/compare.js +40 -0
- package/esm/insight/algorithms/categoryOutlier.js +4 -0
- package/esm/insight/algorithms/changePoint.js +10 -0
- package/esm/insight/algorithms/index.js +3 -0
- package/esm/insight/algorithms/trendDirection.js +4 -0
- package/esm/insight/chart/constants.js +25 -0
- package/esm/insight/chart/generator/homogeneous.js +70 -0
- package/esm/insight/chart/generator/index.js +2 -0
- package/esm/insight/chart/generator/insights.js +16 -0
- package/esm/insight/chart/index.js +4 -0
- package/esm/insight/chart/strategy/augmentedMarks/categoryOutlier.js +30 -0
- package/esm/insight/chart/strategy/augmentedMarks/changePoint.js +42 -0
- package/esm/insight/chart/strategy/augmentedMarks/correlation.js +6 -0
- package/esm/insight/chart/strategy/augmentedMarks/homogeneous.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/index.js +8 -0
- package/esm/insight/chart/strategy/augmentedMarks/lowVariance.js +23 -0
- package/esm/insight/chart/strategy/augmentedMarks/majority.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +82 -0
- package/esm/insight/chart/strategy/augmentedMarks/trend.js +26 -0
- package/esm/insight/chart/strategy/chart.js +45 -0
- package/esm/insight/chart/strategy/commonMarks/areaMark.js +12 -0
- package/esm/insight/chart/strategy/commonMarks/index.js +5 -0
- package/esm/insight/chart/strategy/commonMarks/intervalMark.js +14 -0
- package/esm/insight/chart/strategy/commonMarks/lineMark.js +34 -0
- package/esm/insight/chart/strategy/commonMarks/pointMark.js +17 -0
- package/esm/insight/chart/strategy/commonMarks/textMark.js +28 -0
- package/esm/insight/chart/strategy/index.js +4 -0
- package/esm/insight/chart/strategy/viewSpec.js +16 -0
- package/esm/insight/chart/types.js +1 -0
- package/esm/insight/chart/utils.js +4 -0
- package/esm/insight/constant.js +21 -0
- package/esm/insight/index.js +5 -0
- package/esm/insight/insights/checkers.js +97 -0
- package/esm/insight/insights/extractors/categoryOutlier.js +90 -0
- package/esm/insight/insights/extractors/changePoint.js +55 -0
- package/esm/insight/insights/extractors/correlation.js +38 -0
- package/esm/insight/insights/extractors/homogeneous.js +98 -0
- package/esm/insight/insights/extractors/lowVariance.js +49 -0
- package/esm/insight/insights/extractors/majority.js +66 -0
- package/esm/insight/insights/extractors/timeSeriesOutlier.js +61 -0
- package/esm/insight/insights/extractors/trend.js +49 -0
- package/esm/insight/insights/index.js +28 -0
- package/esm/insight/insights/util.js +77 -0
- package/esm/insight/narrative/factory.js +22 -0
- package/esm/insight/narrative/index.js +14 -0
- package/esm/insight/narrative/strategy/base.js +6 -0
- package/esm/insight/narrative/strategy/categoryOutlier.js +74 -0
- package/esm/insight/narrative/strategy/changePoint.js +52 -0
- package/esm/insight/narrative/strategy/commonness.js +45 -0
- package/esm/insight/narrative/strategy/correlation.js +51 -0
- package/esm/insight/narrative/strategy/exception.js +70 -0
- package/esm/insight/narrative/strategy/helpers.js +25 -0
- package/esm/insight/narrative/strategy/index.js +13 -0
- package/esm/insight/narrative/strategy/lowVariance.js +48 -0
- package/esm/insight/narrative/strategy/majority.js +62 -0
- package/esm/insight/narrative/strategy/timeSeriesOutlier.js +92 -0
- package/esm/insight/narrative/strategy/trend.js +57 -0
- package/esm/insight/pipeline/extract.js +236 -0
- package/esm/insight/pipeline/index.js +11 -0
- package/esm/insight/pipeline/insight.js +81 -0
- package/esm/insight/pipeline/preprocess.js +33 -0
- package/esm/insight/pipeline/specificInsight.js +71 -0
- package/esm/insight/pipeline/util.js +14 -0
- package/esm/insight/pipeline/visualize.js +41 -0
- package/esm/insight/types.js +1 -0
- package/esm/insight/utils/aggregate.js +87 -0
- package/esm/insight/utils/common.js +35 -0
- package/esm/ntv/generate/generateTextSpec.js +157 -0
- package/esm/ntv/generate/index.js +5 -0
- package/esm/ntv/generate/types.js +1 -0
- package/esm/ntv/generate/utils.js +86 -0
- package/esm/ntv/index.js +4 -0
- package/esm/ntv/schema/common.js +1 -0
- package/esm/ntv/schema/index.js +4 -0
- package/esm/ntv/schema/paragraph.js +1 -0
- package/esm/ntv/schema/phrase.js +52 -0
- package/esm/ntv/schema/structure.js +1 -0
- package/esm/ntv/types.js +1 -0
- package/esm/ntv/utils/index.js +1 -0
- package/esm/ntv/utils/isSpecType.js +58 -0
- package/esm/utils/arr2map.js +7 -0
- package/esm/utils/dataFormat.js +32 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/isType.js +14 -0
- package/lib/advisor/advise-pipeline/advicesForChart.d.ts +13 -0
- package/lib/advisor/advise-pipeline/advicesForChart.js +73 -0
- package/lib/advisor/advise-pipeline/data-to-advices.d.ts +22 -0
- package/lib/advisor/advise-pipeline/data-to-advices.js +245 -0
- package/lib/advisor/advise-pipeline/index.d.ts +1 -0
- package/lib/advisor/advise-pipeline/index.js +5 -0
- package/lib/advisor/advise-pipeline/spec-mapping.d.ts +14 -0
- package/lib/advisor/advise-pipeline/spec-mapping.js +504 -0
- package/lib/advisor/advisor.d.ts +18 -0
- package/lib/advisor/advisor.js +38 -0
- package/lib/advisor/constants.d.ts +1 -0
- package/lib/advisor/constants.js +16 -0
- package/lib/advisor/index.d.ts +2 -0
- package/lib/advisor/index.js +7 -0
- package/lib/advisor/lint-pipeline/check-rules.d.ts +4 -0
- package/lib/advisor/lint-pipeline/check-rules.js +47 -0
- package/lib/advisor/lint-pipeline/getChartType.d.ts +7 -0
- package/lib/advisor/lint-pipeline/getChartType.js +113 -0
- package/lib/advisor/lint-pipeline/index.d.ts +0 -0
- package/lib/advisor/lint-pipeline/index.js +0 -0
- package/lib/advisor/lint-pipeline/lintRules.d.ts +5 -0
- package/lib/advisor/lint-pipeline/lintRules.js +36 -0
- package/lib/advisor/ruler/index.d.ts +21 -0
- package/lib/advisor/ruler/index.js +80 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.d.ts +2 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.js +24 -0
- package/lib/advisor/ruler/rules/all-can-be-table.d.ts +2 -0
- package/lib/advisor/ruler/rules/all-can-be-table.js +20 -0
- package/lib/advisor/ruler/rules/bar-series-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-series-qty.js +39 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.js +44 -0
- package/lib/advisor/ruler/rules/constants.d.ts +6 -0
- package/lib/advisor/ruler/rules/constants.js +9 -0
- package/lib/advisor/ruler/rules/data-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-check.js +43 -0
- package/lib/advisor/ruler/rules/data-field-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-field-qty.js +29 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.d.ts +2 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.js +36 -0
- package/lib/advisor/ruler/rules/index.d.ts +19 -0
- package/lib/advisor/ruler/rules/index.js +71 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.d.ts +2 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.js +43 -0
- package/lib/advisor/ruler/rules/limit-series.d.ts +2 -0
- package/lib/advisor/ruler/rules/limit-series.js +50 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.d.ts +2 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.js +28 -0
- package/lib/advisor/ruler/rules/no-redundant-field.d.ts +2 -0
- package/lib/advisor/ruler/rules/no-redundant-field.js +35 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.d.ts +2 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.js +57 -0
- package/lib/advisor/ruler/rules/purpose-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/purpose-check.js +30 -0
- package/lib/advisor/ruler/rules/series-qty-limit.d.ts +2 -0
- package/lib/advisor/ruler/rules/series-qty-limit.js +37 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.d.ts +2 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.js +44 -0
- package/lib/advisor/ruler/types.d.ts +125 -0
- package/lib/advisor/ruler/types.js +2 -0
- package/lib/advisor/ruler/utils.d.ts +10 -0
- package/lib/advisor/ruler/utils.js +61 -0
- package/lib/advisor/types.d.ts +218 -0
- package/lib/advisor/types.js +4 -0
- package/lib/advisor/utils/clone.d.ts +2 -0
- package/lib/advisor/utils/clone.js +34 -0
- package/lib/advisor/utils/compare.d.ts +3 -0
- package/lib/advisor/utils/compare.js +17 -0
- package/lib/advisor/utils/computeScore.d.ts +7 -0
- package/lib/advisor/utils/computeScore.js +27 -0
- package/lib/advisor/utils/deep-mix.d.ts +2 -0
- package/lib/advisor/utils/deep-mix.js +78 -0
- package/lib/advisor/utils/hasSubset.d.ts +1 -0
- package/lib/advisor/utils/hasSubset.js +7 -0
- package/lib/advisor/utils/index.d.ts +5 -0
- package/lib/advisor/utils/index.js +19 -0
- package/lib/advisor/utils/inferDataType.d.ts +6 -0
- package/lib/advisor/utils/inferDataType.js +75 -0
- package/lib/advisor/utils/intersects.d.ts +1 -0
- package/lib/advisor/utils/intersects.js +7 -0
- package/lib/advisor/utils/isNil.d.ts +2 -0
- package/lib/advisor/utils/isNil.js +6 -0
- package/lib/ckb/base.d.ts +2 -0
- package/lib/ckb/base.js +1313 -0
- package/lib/ckb/ckb.d.ts +8 -0
- package/lib/ckb/ckb.js +59 -0
- package/lib/ckb/constants.d.ts +79 -0
- package/lib/ckb/constants.js +200 -0
- package/lib/ckb/i18n/index.d.ts +10 -0
- package/lib/ckb/i18n/index.js +27 -0
- package/lib/ckb/i18n/types.d.ts +52 -0
- package/lib/ckb/i18n/types.js +2 -0
- package/lib/ckb/i18n/zh-CN.d.ts +7 -0
- package/lib/ckb/i18n/zh-CN.js +528 -0
- package/lib/ckb/index.d.ts +4 -0
- package/lib/ckb/index.js +20 -0
- package/lib/ckb/types.d.ts +185 -0
- package/lib/ckb/types.js +2 -0
- package/lib/common/types.d.ts +14 -0
- package/lib/common/types.js +2 -0
- package/lib/data/analysis/field/index.d.ts +79 -0
- package/lib/data/analysis/field/index.js +355 -0
- package/lib/data/analysis/field/types.d.ts +99 -0
- package/lib/data/analysis/field/types.js +2 -0
- package/lib/data/analysis/graph/index.d.ts +28 -0
- package/lib/data/analysis/graph/index.js +178 -0
- package/lib/data/analysis/graph/types.d.ts +62 -0
- package/lib/data/analysis/graph/types.js +2 -0
- package/lib/data/analysis/index.d.ts +1 -0
- package/lib/data/analysis/index.js +5 -0
- package/lib/data/analysis/types.d.ts +1 -0
- package/lib/data/analysis/types.js +2 -0
- package/lib/data/dataset/field/baseFrame.d.ts +30 -0
- package/lib/data/dataset/field/baseFrame.js +78 -0
- package/lib/data/dataset/field/dataFrame.d.ts +35 -0
- package/lib/data/dataset/field/dataFrame.js +558 -0
- package/lib/data/dataset/field/index.d.ts +3 -0
- package/lib/data/dataset/field/index.js +8 -0
- package/lib/data/dataset/field/series.d.ts +18 -0
- package/lib/data/dataset/field/series.js +151 -0
- package/lib/data/dataset/field/types.d.ts +54 -0
- package/lib/data/dataset/field/types.js +2 -0
- package/lib/data/dataset/field/utils.d.ts +13 -0
- package/lib/data/dataset/field/utils.js +68 -0
- package/lib/data/dataset/graph/index.d.ts +18 -0
- package/lib/data/dataset/graph/index.js +188 -0
- package/lib/data/dataset/graph/types.d.ts +35 -0
- package/lib/data/dataset/graph/types.js +2 -0
- package/lib/data/dataset/graph/utils.d.ts +1 -0
- package/lib/data/dataset/graph/utils.js +19 -0
- package/lib/data/dataset/index.d.ts +1 -0
- package/lib/data/dataset/index.js +4 -0
- package/lib/data/dataset/types.d.ts +1 -0
- package/lib/data/dataset/types.js +4 -0
- package/lib/data/index.d.ts +5 -0
- package/lib/data/index.js +8 -0
- package/lib/data/statistics/IQR.d.ts +21 -0
- package/lib/data/statistics/IQR.js +53 -0
- package/lib/data/statistics/base.d.ts +106 -0
- package/lib/data/statistics/base.js +271 -0
- package/lib/data/statistics/bayesian.d.ts +5 -0
- package/lib/data/statistics/bayesian.js +30 -0
- package/lib/data/statistics/buishand-u.d.ts +7 -0
- package/lib/data/statistics/buishand-u.js +23 -0
- package/lib/data/statistics/caches.d.ts +13 -0
- package/lib/data/statistics/caches.js +33 -0
- package/lib/data/statistics/cdf.d.ts +7 -0
- package/lib/data/statistics/cdf.js +29 -0
- package/lib/data/statistics/constants.d.ts +5 -0
- package/lib/data/statistics/constants.js +15 -0
- package/lib/data/statistics/index.d.ts +7 -0
- package/lib/data/statistics/index.js +14 -0
- package/lib/data/statistics/lowess.d.ts +10 -0
- package/lib/data/statistics/lowess.js +87 -0
- package/lib/data/statistics/mannkendall-test.d.ts +15 -0
- package/lib/data/statistics/mannkendall-test.js +54 -0
- package/lib/data/statistics/maxabs.d.ts +5 -0
- package/lib/data/statistics/maxabs.js +13 -0
- package/lib/data/statistics/pcorrtest.d.ts +3 -0
- package/lib/data/statistics/pcorrtest.js +80 -0
- package/lib/data/statistics/pettitt-test.d.ts +9 -0
- package/lib/data/statistics/pettitt-test.js +38 -0
- package/lib/data/statistics/quantile.d.ts +16 -0
- package/lib/data/statistics/quantile.js +61 -0
- package/lib/data/statistics/types.d.ts +70 -0
- package/lib/data/statistics/types.js +2 -0
- package/lib/data/statistics/vector.d.ts +15 -0
- package/lib/data/statistics/vector.js +78 -0
- package/lib/data/statistics/window.d.ts +12 -0
- package/lib/data/statistics/window.js +60 -0
- package/lib/data/types.d.ts +2 -0
- package/lib/data/types.js +5 -0
- package/lib/data/utils/common.d.ts +26 -0
- package/lib/data/utils/common.js +67 -0
- package/lib/data/utils/index.d.ts +2 -0
- package/lib/data/utils/index.js +8 -0
- package/lib/data/utils/isType/constants.d.ts +15 -0
- package/lib/data/utils/isType/constants.js +27 -0
- package/lib/data/utils/isType/index.d.ts +2 -0
- package/lib/data/utils/isType/index.js +5 -0
- package/lib/data/utils/isType/isDateString.d.ts +18 -0
- package/lib/data/utils/isType/isDateString.js +111 -0
- package/lib/data/utils/isType/isType.d.ts +13 -0
- package/lib/data/utils/isType/isType.js +94 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +75 -0
- package/lib/insight/algorithms/base/compare.d.ts +14 -0
- package/lib/insight/algorithms/base/compare.js +45 -0
- package/lib/insight/algorithms/categoryOutlier.d.ts +4 -0
- package/lib/insight/algorithms/categoryOutlier.js +7 -0
- package/lib/insight/algorithms/changePoint.d.ts +10 -0
- package/lib/insight/algorithms/changePoint.js +13 -0
- package/lib/insight/algorithms/index.d.ts +3 -0
- package/lib/insight/algorithms/index.js +6 -0
- package/lib/insight/algorithms/trendDirection.d.ts +4 -0
- package/lib/insight/algorithms/trendDirection.js +7 -0
- package/lib/insight/chart/constants.d.ts +13 -0
- package/lib/insight/chart/constants.js +28 -0
- package/lib/insight/chart/generator/homogeneous.d.ts +3 -0
- package/lib/insight/chart/generator/homogeneous.js +75 -0
- package/lib/insight/chart/generator/index.d.ts +2 -0
- package/lib/insight/chart/generator/index.js +5 -0
- package/lib/insight/chart/generator/insights.d.ts +3 -0
- package/lib/insight/chart/generator/insights.js +20 -0
- package/lib/insight/chart/index.d.ts +4 -0
- package/lib/insight/chart/index.js +7 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.js +35 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.js +47 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.js +10 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.d.ts +8 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.js +24 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.js +28 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +87 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.js +31 -0
- package/lib/insight/chart/strategy/chart.d.ts +7 -0
- package/lib/insight/chart/strategy/chart.js +49 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.js +16 -0
- package/lib/insight/chart/strategy/commonMarks/index.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/index.js +13 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.js +18 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.js +38 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.js +21 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.js +32 -0
- package/lib/insight/chart/strategy/index.d.ts +4 -0
- package/lib/insight/chart/strategy/index.js +10 -0
- package/lib/insight/chart/strategy/viewSpec.d.ts +3 -0
- package/lib/insight/chart/strategy/viewSpec.js +20 -0
- package/lib/insight/chart/types.d.ts +60 -0
- package/lib/insight/chart/types.js +2 -0
- package/lib/insight/chart/utils.d.ts +3 -0
- package/lib/insight/chart/utils.js +8 -0
- package/lib/insight/constant.d.ts +12 -0
- package/lib/insight/constant.js +24 -0
- package/lib/insight/index.d.ts +6 -0
- package/lib/insight/index.js +13 -0
- package/lib/insight/insights/checkers.d.ts +16 -0
- package/lib/insight/insights/checkers.js +107 -0
- package/lib/insight/insights/extractors/categoryOutlier.d.ts +12 -0
- package/lib/insight/insights/extractors/categoryOutlier.js +95 -0
- package/lib/insight/insights/extractors/changePoint.d.ts +8 -0
- package/lib/insight/insights/extractors/changePoint.js +60 -0
- package/lib/insight/insights/extractors/correlation.d.ts +9 -0
- package/lib/insight/insights/extractors/correlation.js +43 -0
- package/lib/insight/insights/extractors/homogeneous.d.ts +4 -0
- package/lib/insight/insights/extractors/homogeneous.js +103 -0
- package/lib/insight/insights/extractors/lowVariance.d.ts +8 -0
- package/lib/insight/insights/extractors/lowVariance.js +54 -0
- package/lib/insight/insights/extractors/majority.d.ts +10 -0
- package/lib/insight/insights/extractors/majority.js +71 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.d.ts +2 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.js +65 -0
- package/lib/insight/insights/extractors/trend.d.ts +9 -0
- package/lib/insight/insights/extractors/trend.js +54 -0
- package/lib/insight/insights/index.d.ts +12 -0
- package/lib/insight/insights/index.js +32 -0
- package/lib/insight/insights/util.d.ts +13 -0
- package/lib/insight/insights/util.js +87 -0
- package/lib/insight/narrative/factory.d.ts +6 -0
- package/lib/insight/narrative/factory.js +25 -0
- package/lib/insight/narrative/index.d.ts +3 -0
- package/lib/insight/narrative/index.js +18 -0
- package/lib/insight/narrative/strategy/base.d.ts +9 -0
- package/lib/insight/narrative/strategy/base.js +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.d.ts +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.js +76 -0
- package/lib/insight/narrative/strategy/changePoint.d.ts +8 -0
- package/lib/insight/narrative/strategy/changePoint.js +54 -0
- package/lib/insight/narrative/strategy/commonness.d.ts +9 -0
- package/lib/insight/narrative/strategy/commonness.js +47 -0
- package/lib/insight/narrative/strategy/correlation.d.ts +8 -0
- package/lib/insight/narrative/strategy/correlation.js +53 -0
- package/lib/insight/narrative/strategy/exception.d.ts +10 -0
- package/lib/insight/narrative/strategy/exception.js +72 -0
- package/lib/insight/narrative/strategy/helpers.d.ts +5 -0
- package/lib/insight/narrative/strategy/helpers.js +31 -0
- package/lib/insight/narrative/strategy/index.d.ts +9 -0
- package/lib/insight/narrative/strategy/index.js +28 -0
- package/lib/insight/narrative/strategy/lowVariance.d.ts +8 -0
- package/lib/insight/narrative/strategy/lowVariance.js +50 -0
- package/lib/insight/narrative/strategy/majority.d.ts +8 -0
- package/lib/insight/narrative/strategy/majority.js +64 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.d.ts +8 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.js +94 -0
- package/lib/insight/narrative/strategy/trend.d.ts +8 -0
- package/lib/insight/narrative/strategy/trend.js +59 -0
- package/lib/insight/pipeline/extract.d.ts +13 -0
- package/lib/insight/pipeline/extract.js +243 -0
- package/lib/insight/pipeline/index.d.ts +2 -0
- package/lib/insight/pipeline/index.js +15 -0
- package/lib/insight/pipeline/insight.d.ts +10 -0
- package/lib/insight/pipeline/insight.js +86 -0
- package/lib/insight/pipeline/preprocess.d.ts +6 -0
- package/lib/insight/pipeline/preprocess.js +39 -0
- package/lib/insight/pipeline/specificInsight.d.ts +11 -0
- package/lib/insight/pipeline/specificInsight.js +79 -0
- package/lib/insight/pipeline/util.d.ts +5 -0
- package/lib/insight/pipeline/util.js +20 -0
- package/lib/insight/pipeline/visualize.d.ts +3 -0
- package/lib/insight/pipeline/visualize.js +46 -0
- package/lib/insight/types.d.ts +238 -0
- package/lib/insight/types.js +2 -0
- package/lib/insight/utils/aggregate.d.ts +7 -0
- package/lib/insight/utils/aggregate.js +93 -0
- package/lib/insight/utils/common.d.ts +3 -0
- package/lib/insight/utils/common.js +41 -0
- package/lib/ntv/generate/generateTextSpec.d.ts +9 -0
- package/lib/ntv/generate/generateTextSpec.js +160 -0
- package/lib/ntv/generate/index.d.ts +2 -0
- package/lib/ntv/generate/index.js +12 -0
- package/lib/ntv/generate/types.d.ts +58 -0
- package/lib/ntv/generate/types.js +2 -0
- package/lib/ntv/generate/utils.d.ts +29 -0
- package/lib/ntv/generate/utils.js +96 -0
- package/lib/ntv/index.d.ts +4 -0
- package/lib/ntv/index.js +10 -0
- package/lib/ntv/schema/common.d.ts +17 -0
- package/lib/ntv/schema/common.js +2 -0
- package/lib/ntv/schema/index.d.ts +4 -0
- package/lib/ntv/schema/index.js +7 -0
- package/lib/ntv/schema/paragraph.d.ts +34 -0
- package/lib/ntv/schema/paragraph.js +2 -0
- package/lib/ntv/schema/phrase.d.ts +70 -0
- package/lib/ntv/schema/phrase.js +55 -0
- package/lib/ntv/schema/structure.d.ts +18 -0
- package/lib/ntv/schema/structure.js +2 -0
- package/lib/ntv/types.d.ts +2 -0
- package/lib/ntv/types.js +2 -0
- package/lib/ntv/utils/index.d.ts +1 -0
- package/lib/ntv/utils/index.js +4 -0
- package/lib/ntv/utils/isSpecType.d.ts +17 -0
- package/lib/ntv/utils/isSpecType.js +76 -0
- package/lib/utils/arr2map.d.ts +1 -0
- package/lib/utils/arr2map.js +11 -0
- package/lib/utils/dataFormat.d.ts +11 -0
- package/lib/utils/dataFormat.js +35 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/isType.d.ts +4 -0
- package/lib/utils/isType.js +21 -0
- package/package.json +88 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InsightType, InsightInfo, Language, HomogeneousInsightType, HomogeneousPatternInfo } from '../../types';
|
|
2
|
+
import type { ParagraphSpec, Structure, StructureTemp } from '../../../ntv/types';
|
|
3
|
+
export type HomogeneousInsightInfo = HomogeneousPatternInfo & Omit<InsightInfo, 'patterns'>;
|
|
4
|
+
export declare abstract class InsightNarrativeStrategy<P = any> {
|
|
5
|
+
static insightType: InsightType | HomogeneousInsightType;
|
|
6
|
+
protected static structures: Record<Language, Structure[]>;
|
|
7
|
+
protected static structureTemps?: Record<Language, StructureTemp[]>;
|
|
8
|
+
abstract generateTextSpec(insightInfo: InsightInfo<P> | HomogeneousInsightInfo, lang: Language): ParagraphSpec[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsightNarrativeStrategy = void 0;
|
|
4
|
+
var InsightNarrativeStrategy = /** @class */ (function () {
|
|
5
|
+
function InsightNarrativeStrategy() {
|
|
6
|
+
}
|
|
7
|
+
return InsightNarrativeStrategy;
|
|
8
|
+
}());
|
|
9
|
+
exports.InsightNarrativeStrategy = InsightNarrativeStrategy;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { InsightType, Language, InsightInfo, CategoryOutlierInfo } from '../../types';
|
|
3
|
+
import type { ParagraphSpec, Structure, StructureTemp } from '../../../ntv/types';
|
|
4
|
+
export default class CategoryOutlierNarrativeStrategy extends InsightNarrativeStrategy<CategoryOutlierInfo> {
|
|
5
|
+
static readonly insightType: InsightType;
|
|
6
|
+
protected static structures: Record<Language, Structure[]>;
|
|
7
|
+
protected static structureTemps: Record<Language, StructureTemp[]>;
|
|
8
|
+
generateTextSpec(insightInfo: InsightInfo<CategoryOutlierInfo>, lang: Language): ParagraphSpec[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-template-curly-in-string */
|
|
5
|
+
var ntv_1 = require("../../../ntv");
|
|
6
|
+
var base_1 = require("./base");
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
var variableMetaMap = {
|
|
9
|
+
measure: {
|
|
10
|
+
varType: 'metric_name',
|
|
11
|
+
},
|
|
12
|
+
total: {
|
|
13
|
+
varType: 'metric_value',
|
|
14
|
+
},
|
|
15
|
+
'.x': {
|
|
16
|
+
varType: 'dim_value',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
var CategoryOutlierNarrativeStrategy = /** @class */ (function (_super) {
|
|
20
|
+
tslib_1.__extends(CategoryOutlierNarrativeStrategy, _super);
|
|
21
|
+
function CategoryOutlierNarrativeStrategy() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
CategoryOutlierNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
25
|
+
var patterns = insightInfo.patterns;
|
|
26
|
+
var _a = patterns[0], dimension = _a.dimension, measure = _a.measure;
|
|
27
|
+
var spec = (0, ntv_1.generateTextSpec)({
|
|
28
|
+
structures: CategoryOutlierNarrativeStrategy.structures[lang],
|
|
29
|
+
variable: {
|
|
30
|
+
dimension: dimension,
|
|
31
|
+
measure: measure,
|
|
32
|
+
total: patterns.length,
|
|
33
|
+
patterns: patterns,
|
|
34
|
+
},
|
|
35
|
+
structureTemps: CategoryOutlierNarrativeStrategy.structureTemps[lang],
|
|
36
|
+
});
|
|
37
|
+
return spec.sections[0].paragraphs;
|
|
38
|
+
};
|
|
39
|
+
CategoryOutlierNarrativeStrategy.insightType = 'category_outlier';
|
|
40
|
+
CategoryOutlierNarrativeStrategy.structures = {
|
|
41
|
+
'zh-CN': [
|
|
42
|
+
{
|
|
43
|
+
template: '${measure} 在 ${dimension} 上有 ${total} 个类别相比其他维值突出:&{outliers}。',
|
|
44
|
+
variableMetaMap: variableMetaMap,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
'en-US': [
|
|
48
|
+
{
|
|
49
|
+
template: '${measure} has ${total} categories in the ${dimension} that are prominent compared to other dimensions: &{outliers}.',
|
|
50
|
+
variableMetaMap: variableMetaMap,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
CategoryOutlierNarrativeStrategy.structureTemps = {
|
|
55
|
+
'zh-CN': [
|
|
56
|
+
{
|
|
57
|
+
templateId: 'outliers',
|
|
58
|
+
template: '${.x}',
|
|
59
|
+
separator: (0, helpers_1.getDefaultSeparator)('zh-CN'),
|
|
60
|
+
variableMetaMap: variableMetaMap,
|
|
61
|
+
useVariable: 'patterns',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
'en-US': [
|
|
65
|
+
{
|
|
66
|
+
templateId: 'outliers',
|
|
67
|
+
template: '${.x}',
|
|
68
|
+
separator: (0, helpers_1.getDefaultSeparator)('en-US'),
|
|
69
|
+
variableMetaMap: variableMetaMap,
|
|
70
|
+
useVariable: 'patterns',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
return CategoryOutlierNarrativeStrategy;
|
|
75
|
+
}(base_1.InsightNarrativeStrategy));
|
|
76
|
+
exports.default = CategoryOutlierNarrativeStrategy;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { InsightType, Language, InsightInfo, ChangePointInfo } from '../../types';
|
|
3
|
+
import type { ParagraphSpec, Structure } from '../../../ntv/types';
|
|
4
|
+
export default class ChangePointNarrativeStrategy extends InsightNarrativeStrategy<ChangePointInfo> {
|
|
5
|
+
static readonly insightType: InsightType;
|
|
6
|
+
protected static structures: Record<Language, Structure[]>;
|
|
7
|
+
generateTextSpec(insightInfo: InsightInfo<ChangePointInfo>, lang: Language): ParagraphSpec[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-template-curly-in-string */
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
var ntv_1 = require("../../../ntv");
|
|
7
|
+
var base_1 = require("./base");
|
|
8
|
+
var variableMetaMap = {
|
|
9
|
+
dateRange: {
|
|
10
|
+
varType: 'time_desc',
|
|
11
|
+
},
|
|
12
|
+
total: {
|
|
13
|
+
varType: 'metric_value',
|
|
14
|
+
},
|
|
15
|
+
measure: {
|
|
16
|
+
varType: 'metric_name',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
var ChangePointNarrativeStrategy = /** @class */ (function (_super) {
|
|
20
|
+
tslib_1.__extends(ChangePointNarrativeStrategy, _super);
|
|
21
|
+
function ChangePointNarrativeStrategy() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
ChangePointNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
25
|
+
var patterns = insightInfo.patterns, data = insightInfo.data;
|
|
26
|
+
var dimension = patterns[0].dimension;
|
|
27
|
+
var spec = (0, ntv_1.generateTextSpec)({
|
|
28
|
+
structures: ChangePointNarrativeStrategy.structures[lang],
|
|
29
|
+
variable: {
|
|
30
|
+
dateRange: "".concat((0, lodash_1.first)(data)[dimension], "~").concat((0, lodash_1.last)(data)[dimension]),
|
|
31
|
+
measure: patterns[0].measure,
|
|
32
|
+
total: patterns.length,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return spec.sections[0].paragraphs;
|
|
36
|
+
};
|
|
37
|
+
ChangePointNarrativeStrategy.insightType = 'change_point';
|
|
38
|
+
ChangePointNarrativeStrategy.structures = {
|
|
39
|
+
'zh-CN': [
|
|
40
|
+
{
|
|
41
|
+
template: '${measure} 在 ${dateRange} 中,共出现 ${total} 次较大变化,值得关注。',
|
|
42
|
+
variableMetaMap: variableMetaMap,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
'en-US': [
|
|
46
|
+
{
|
|
47
|
+
template: 'In ${dateRange}, ${measure} has ${total} major changes, which is worthy of attention.',
|
|
48
|
+
variableMetaMap: variableMetaMap,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
return ChangePointNarrativeStrategy;
|
|
53
|
+
}(base_1.InsightNarrativeStrategy));
|
|
54
|
+
exports.default = ChangePointNarrativeStrategy;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { HomogeneousInsightInfo } from './base';
|
|
3
|
+
import type { Language, HomogeneousPatternInfo, HomogeneousInsightType } from '../../types';
|
|
4
|
+
import type { ParagraphSpec, Structure } from '../../../ntv/types';
|
|
5
|
+
export default class CommonnessNarrativeStrategy extends InsightNarrativeStrategy<HomogeneousPatternInfo> {
|
|
6
|
+
static readonly insightType: HomogeneousInsightType;
|
|
7
|
+
protected static structures: Record<Language, Structure[]>;
|
|
8
|
+
generateTextSpec(insightInfo: HomogeneousInsightInfo, lang: Language): ParagraphSpec[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-template-curly-in-string */
|
|
5
|
+
var ntv_1 = require("../../../ntv");
|
|
6
|
+
var base_1 = require("./base");
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
var variableMetaMap = {
|
|
9
|
+
measures: {
|
|
10
|
+
varType: 'metric_name',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
var CommonnessNarrativeStrategy = /** @class */ (function (_super) {
|
|
14
|
+
tslib_1.__extends(CommonnessNarrativeStrategy, _super);
|
|
15
|
+
function CommonnessNarrativeStrategy() {
|
|
16
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
17
|
+
}
|
|
18
|
+
CommonnessNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
19
|
+
var measures = insightInfo.measures, dimensions = insightInfo.dimensions, insightType = insightInfo.insightType;
|
|
20
|
+
var spec = (0, ntv_1.generateTextSpec)({
|
|
21
|
+
structures: CommonnessNarrativeStrategy.structures[lang],
|
|
22
|
+
variable: {
|
|
23
|
+
measures: measures.map(function (m) { return m.fieldName; }).join((0, helpers_1.getDefaultSeparator)(lang)),
|
|
24
|
+
dimensions: dimensions.map(function (m) { return m.fieldName; }).join((0, helpers_1.getDefaultSeparator)(lang)),
|
|
25
|
+
insightType: (0, helpers_1.getInsightName)(insightType, lang),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return spec.sections[0].paragraphs;
|
|
29
|
+
};
|
|
30
|
+
CommonnessNarrativeStrategy.insightType = 'commonness';
|
|
31
|
+
CommonnessNarrativeStrategy.structures = {
|
|
32
|
+
'zh-CN': [
|
|
33
|
+
{
|
|
34
|
+
template: '大部分 ${dimensions} 的维值在 ${measures} 上具有 ${insightType}。',
|
|
35
|
+
variableMetaMap: variableMetaMap,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
'en-US': [
|
|
39
|
+
{
|
|
40
|
+
template: 'Most of the dimension values of ${dimensions} have ${insightType} on ${measures}.',
|
|
41
|
+
variableMetaMap: variableMetaMap,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
return CommonnessNarrativeStrategy;
|
|
46
|
+
}(base_1.InsightNarrativeStrategy));
|
|
47
|
+
exports.default = CommonnessNarrativeStrategy;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { InsightType, Language, InsightInfo, CorrelationInfo } from '../../types';
|
|
3
|
+
import type { ParagraphSpec, Structure } from '../../../ntv/types';
|
|
4
|
+
export default class CorrelationNarrativeStrategy extends InsightNarrativeStrategy<CorrelationInfo> {
|
|
5
|
+
static readonly insightType: InsightType;
|
|
6
|
+
protected static structures: Record<Language, Structure[]>;
|
|
7
|
+
generateTextSpec(insightInfo: InsightInfo<CorrelationInfo>, lang: Language): ParagraphSpec[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-template-curly-in-string */
|
|
5
|
+
var ntv_1 = require("../../../ntv");
|
|
6
|
+
var base_1 = require("./base");
|
|
7
|
+
var variableMetaMap = {
|
|
8
|
+
pcorr: {
|
|
9
|
+
varType: 'metric_value',
|
|
10
|
+
},
|
|
11
|
+
m1: {
|
|
12
|
+
varType: 'metric_value',
|
|
13
|
+
},
|
|
14
|
+
m2: {
|
|
15
|
+
varType: 'metric_value',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
var CorrelationNarrativeStrategy = /** @class */ (function (_super) {
|
|
19
|
+
tslib_1.__extends(CorrelationNarrativeStrategy, _super);
|
|
20
|
+
function CorrelationNarrativeStrategy() {
|
|
21
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
22
|
+
}
|
|
23
|
+
CorrelationNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
24
|
+
var patterns = insightInfo.patterns;
|
|
25
|
+
var _a = patterns[0], _b = tslib_1.__read(_a.measures, 2), m1 = _b[0], m2 = _b[1], pcorr = _a.pcorr;
|
|
26
|
+
var spec = (0, ntv_1.generateTextSpec)({
|
|
27
|
+
structures: CorrelationNarrativeStrategy.structures[lang],
|
|
28
|
+
variable: {
|
|
29
|
+
m1: m1,
|
|
30
|
+
m2: m2,
|
|
31
|
+
pcorr: pcorr,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return spec.sections[0].paragraphs;
|
|
35
|
+
};
|
|
36
|
+
CorrelationNarrativeStrategy.insightType = 'correlation';
|
|
37
|
+
CorrelationNarrativeStrategy.structures = {
|
|
38
|
+
'zh-CN': [
|
|
39
|
+
{
|
|
40
|
+
template: '${m1} 与 ${m2} 相关性最大,相关系数为 ${pcorr}。',
|
|
41
|
+
variableMetaMap: variableMetaMap,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
'en-US': [
|
|
45
|
+
{
|
|
46
|
+
template: '${m1} is most correlated with ${m2} with a correlation coefficient of ${pcorr}.',
|
|
47
|
+
variableMetaMap: variableMetaMap,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
return CorrelationNarrativeStrategy;
|
|
52
|
+
}(base_1.InsightNarrativeStrategy));
|
|
53
|
+
exports.default = CorrelationNarrativeStrategy;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { HomogeneousInsightInfo } from './base';
|
|
3
|
+
import type { Language, HomogeneousPatternInfo, HomogeneousInsightType } from '../../types';
|
|
4
|
+
import type { ParagraphSpec, Structure, StructureTemp } from '../../../ntv/types';
|
|
5
|
+
export default class ExceptionNarrativeStrategy extends InsightNarrativeStrategy<HomogeneousPatternInfo> {
|
|
6
|
+
static readonly insightType: HomogeneousInsightType;
|
|
7
|
+
protected static structures: Record<Language, Structure[]>;
|
|
8
|
+
protected static structureTemps: Record<Language, StructureTemp[]>;
|
|
9
|
+
generateTextSpec(insightInfo: HomogeneousInsightInfo, lang: Language): ParagraphSpec[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-template-curly-in-string */
|
|
5
|
+
var ntv_1 = require("../../../ntv");
|
|
6
|
+
var base_1 = require("./base");
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
var variableMetaMap = {
|
|
9
|
+
measures: {
|
|
10
|
+
varType: 'metric_name',
|
|
11
|
+
},
|
|
12
|
+
'.dim': {
|
|
13
|
+
varType: 'dim_value',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
var ExceptionNarrativeStrategy = /** @class */ (function (_super) {
|
|
17
|
+
tslib_1.__extends(ExceptionNarrativeStrategy, _super);
|
|
18
|
+
function ExceptionNarrativeStrategy() {
|
|
19
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
20
|
+
}
|
|
21
|
+
ExceptionNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
22
|
+
var measures = insightInfo.measures, dimensions = insightInfo.dimensions, insightType = insightInfo.insightType, exceptions = insightInfo.exceptions;
|
|
23
|
+
var spec = (0, ntv_1.generateTextSpec)({
|
|
24
|
+
structures: ExceptionNarrativeStrategy.structures[lang],
|
|
25
|
+
structureTemps: ExceptionNarrativeStrategy.structureTemps[lang],
|
|
26
|
+
variable: {
|
|
27
|
+
measures: measures.map(function (m) { return m.fieldName; }).join((0, helpers_1.getDefaultSeparator)(lang)),
|
|
28
|
+
dimensions: dimensions.map(function (m) { return m.fieldName; }).join((0, helpers_1.getDefaultSeparator)(lang)),
|
|
29
|
+
insightType: (0, helpers_1.getInsightName)(insightType, lang),
|
|
30
|
+
exceptions: exceptions.map(function (dim) { return ({ dim: dim }); }),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return spec.sections[0].paragraphs;
|
|
34
|
+
};
|
|
35
|
+
ExceptionNarrativeStrategy.insightType = 'exception';
|
|
36
|
+
ExceptionNarrativeStrategy.structures = {
|
|
37
|
+
'zh-CN': [
|
|
38
|
+
{
|
|
39
|
+
template: '大部分 ${dimensions} 的维值在 ${measures} 上具有 ${insightType},除了&{exceptionList}。',
|
|
40
|
+
variableMetaMap: variableMetaMap,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
'en-US': [
|
|
44
|
+
{
|
|
45
|
+
template: 'Most of the dimension values of ${dimensions} have ${insightType} on ${measures}, except for &{exceptionList}.',
|
|
46
|
+
variableMetaMap: variableMetaMap,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
ExceptionNarrativeStrategy.structureTemps = {
|
|
51
|
+
'zh-CN': [
|
|
52
|
+
{
|
|
53
|
+
templateId: 'exceptionList',
|
|
54
|
+
template: '${.dim}',
|
|
55
|
+
useVariable: 'exceptions',
|
|
56
|
+
separator: (0, helpers_1.getDefaultSeparator)('zh-CN'),
|
|
57
|
+
variableMetaMap: variableMetaMap,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
'en-US': [
|
|
61
|
+
{
|
|
62
|
+
templateId: 'exceptionList',
|
|
63
|
+
template: '${.dim}',
|
|
64
|
+
useVariable: 'exceptions',
|
|
65
|
+
separator: (0, helpers_1.getDefaultSeparator)('en-US'),
|
|
66
|
+
variableMetaMap: variableMetaMap,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
return ExceptionNarrativeStrategy;
|
|
71
|
+
}(base_1.InsightNarrativeStrategy));
|
|
72
|
+
exports.default = ExceptionNarrativeStrategy;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Language, InsightType } from '../../types';
|
|
2
|
+
export declare const getDiffDesc: (value: number, lang: Language) => "equal" | "more than" | "超过" | "less than" | "少于" | "持平";
|
|
3
|
+
export declare const INSIGHT_TYPE_NAME: Record<InsightType, string>;
|
|
4
|
+
export declare const getInsightName: (insightType: InsightType, lang: Language) => string;
|
|
5
|
+
export declare const getDefaultSeparator: (lang: Language) => "," | ", ";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultSeparator = exports.getInsightName = exports.INSIGHT_TYPE_NAME = exports.getDiffDesc = void 0;
|
|
4
|
+
var lodash_1 = require("lodash");
|
|
5
|
+
var getDiffDesc = function (value, lang) {
|
|
6
|
+
if (value > 0)
|
|
7
|
+
return lang === 'en-US' ? 'more than' : '超过';
|
|
8
|
+
if (value < 0)
|
|
9
|
+
return lang === 'en-US' ? 'less than' : '少于';
|
|
10
|
+
return lang === 'en-US' ? 'equal' : '持平';
|
|
11
|
+
};
|
|
12
|
+
exports.getDiffDesc = getDiffDesc;
|
|
13
|
+
exports.INSIGHT_TYPE_NAME = {
|
|
14
|
+
change_point: '突变点',
|
|
15
|
+
time_series_outlier: '时序异常值',
|
|
16
|
+
trend: '趋势',
|
|
17
|
+
majority: '主要因素',
|
|
18
|
+
low_variance: '分布均匀',
|
|
19
|
+
category_outlier: '异常值',
|
|
20
|
+
correlation: '相关性',
|
|
21
|
+
};
|
|
22
|
+
var getInsightName = function (insightType, lang) {
|
|
23
|
+
if (lang === 'en-US')
|
|
24
|
+
return (0, lodash_1.lowerCase)(insightType);
|
|
25
|
+
return exports.INSIGHT_TYPE_NAME[insightType];
|
|
26
|
+
};
|
|
27
|
+
exports.getInsightName = getInsightName;
|
|
28
|
+
var getDefaultSeparator = function (lang) {
|
|
29
|
+
return lang === 'zh-CN' ? ',' : ', ';
|
|
30
|
+
};
|
|
31
|
+
exports.getDefaultSeparator = getDefaultSeparator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as ChangePointNarrativeStrategy } from './changePoint';
|
|
2
|
+
export { default as TimeSeriesOutlierNarrativeStrategy } from './timeSeriesOutlier';
|
|
3
|
+
export { default as TrendNarrativeStrategy } from './trend';
|
|
4
|
+
export { default as MajorityNarrativeStrategy } from './majority';
|
|
5
|
+
export { default as LowVarianceNarrativeStrategy } from './lowVariance';
|
|
6
|
+
export { default as CategoryNarrativeStrategy } from './categoryOutlier';
|
|
7
|
+
export { default as CorrelationNarrativeStrategy } from './correlation';
|
|
8
|
+
export { default as CommonnessNarrativeStrategy } from './commonness';
|
|
9
|
+
export { default as ExceptionNarrativeStrategy } from './exception';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ExceptionNarrativeStrategy = exports.CommonnessNarrativeStrategy = exports.CorrelationNarrativeStrategy = exports.CategoryNarrativeStrategy = exports.LowVarianceNarrativeStrategy = exports.MajorityNarrativeStrategy = exports.TrendNarrativeStrategy = exports.TimeSeriesOutlierNarrativeStrategy = exports.ChangePointNarrativeStrategy = void 0;
|
|
7
|
+
// 趋势类 trend
|
|
8
|
+
var changePoint_1 = require("./changePoint");
|
|
9
|
+
Object.defineProperty(exports, "ChangePointNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(changePoint_1).default; } });
|
|
10
|
+
var timeSeriesOutlier_1 = require("./timeSeriesOutlier");
|
|
11
|
+
Object.defineProperty(exports, "TimeSeriesOutlierNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(timeSeriesOutlier_1).default; } });
|
|
12
|
+
var trend_1 = require("./trend");
|
|
13
|
+
Object.defineProperty(exports, "TrendNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(trend_1).default; } });
|
|
14
|
+
// 分布类 distribute
|
|
15
|
+
var majority_1 = require("./majority");
|
|
16
|
+
Object.defineProperty(exports, "MajorityNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(majority_1).default; } });
|
|
17
|
+
var lowVariance_1 = require("./lowVariance");
|
|
18
|
+
Object.defineProperty(exports, "LowVarianceNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(lowVariance_1).default; } });
|
|
19
|
+
var categoryOutlier_1 = require("./categoryOutlier");
|
|
20
|
+
Object.defineProperty(exports, "CategoryNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(categoryOutlier_1).default; } });
|
|
21
|
+
// 多指标 multi metric
|
|
22
|
+
var correlation_1 = require("./correlation");
|
|
23
|
+
Object.defineProperty(exports, "CorrelationNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(correlation_1).default; } });
|
|
24
|
+
// 共性/例外 homogeneous
|
|
25
|
+
var commonness_1 = require("./commonness");
|
|
26
|
+
Object.defineProperty(exports, "CommonnessNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(commonness_1).default; } });
|
|
27
|
+
var exception_1 = require("./exception");
|
|
28
|
+
Object.defineProperty(exports, "ExceptionNarrativeStrategy", { enumerable: true, get: function () { return __importDefault(exception_1).default; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { InsightType, Language, InsightInfo, LowVarianceInfo } from '../../types';
|
|
3
|
+
import type { ParagraphSpec, Structure } from '../../../ntv/types';
|
|
4
|
+
export default class LowVarianceNarrativeStrategy extends InsightNarrativeStrategy<LowVarianceInfo> {
|
|
5
|
+
static readonly insightType: InsightType;
|
|
6
|
+
protected static structures: Record<Language, Structure[]>;
|
|
7
|
+
generateTextSpec(insightInfo: InsightInfo<LowVarianceInfo>, lang: Language): ParagraphSpec[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-template-curly-in-string */
|
|
5
|
+
var ntv_1 = require("../../../ntv");
|
|
6
|
+
var base_1 = require("./base");
|
|
7
|
+
var variableMetaMap = {
|
|
8
|
+
measure: {
|
|
9
|
+
varType: 'metric_name',
|
|
10
|
+
},
|
|
11
|
+
mean: {
|
|
12
|
+
varType: 'metric_value',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
var LowVarianceNarrativeStrategy = /** @class */ (function (_super) {
|
|
16
|
+
tslib_1.__extends(LowVarianceNarrativeStrategy, _super);
|
|
17
|
+
function LowVarianceNarrativeStrategy() {
|
|
18
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
19
|
+
}
|
|
20
|
+
LowVarianceNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
21
|
+
var patterns = insightInfo.patterns;
|
|
22
|
+
var _a = patterns[0], dimension = _a.dimension, measure = _a.measure, mean = _a.mean;
|
|
23
|
+
var spec = (0, ntv_1.generateTextSpec)({
|
|
24
|
+
structures: LowVarianceNarrativeStrategy.structures[lang],
|
|
25
|
+
variable: {
|
|
26
|
+
dimension: dimension,
|
|
27
|
+
measure: measure,
|
|
28
|
+
mean: mean,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return spec.sections[0].paragraphs;
|
|
32
|
+
};
|
|
33
|
+
LowVarianceNarrativeStrategy.insightType = 'low_variance';
|
|
34
|
+
LowVarianceNarrativeStrategy.structures = {
|
|
35
|
+
'zh-CN': [
|
|
36
|
+
{
|
|
37
|
+
template: '按照 ${dimension} 对 ${measure} 进行拆解,指标分布均匀,平均为 ${mean}。',
|
|
38
|
+
variableMetaMap: variableMetaMap,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
'en-US': [
|
|
42
|
+
{
|
|
43
|
+
template: 'The quantity is disassembled according to ${dimension}, and ${measure} are evenly distributed, with an average of ${mean}.',
|
|
44
|
+
variableMetaMap: variableMetaMap,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
return LowVarianceNarrativeStrategy;
|
|
49
|
+
}(base_1.InsightNarrativeStrategy));
|
|
50
|
+
exports.default = LowVarianceNarrativeStrategy;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { InsightType, Language, InsightInfo, MajorityInfo } from '../../types';
|
|
3
|
+
import type { ParagraphSpec, Structure } from '../../../ntv/types';
|
|
4
|
+
export default class MajorityNarrativeStrategy extends InsightNarrativeStrategy<MajorityInfo> {
|
|
5
|
+
static readonly insightType: InsightType;
|
|
6
|
+
protected static structures: Record<Language, Structure[]>;
|
|
7
|
+
generateTextSpec(insightInfo: InsightInfo<MajorityInfo>, lang: Language): ParagraphSpec[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-template-curly-in-string */
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
var ntv_1 = require("../../../ntv");
|
|
7
|
+
var base_1 = require("./base");
|
|
8
|
+
var variableMetaMap = {
|
|
9
|
+
measure: {
|
|
10
|
+
varType: 'metric_name',
|
|
11
|
+
},
|
|
12
|
+
total: {
|
|
13
|
+
varType: 'metric_value',
|
|
14
|
+
},
|
|
15
|
+
proportion: {
|
|
16
|
+
varType: 'proportion',
|
|
17
|
+
},
|
|
18
|
+
dimValue: {
|
|
19
|
+
varType: 'dim_value',
|
|
20
|
+
},
|
|
21
|
+
y: {
|
|
22
|
+
varType: 'metric_value',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
var MajorityNarrativeStrategy = /** @class */ (function (_super) {
|
|
26
|
+
tslib_1.__extends(MajorityNarrativeStrategy, _super);
|
|
27
|
+
function MajorityNarrativeStrategy() {
|
|
28
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
29
|
+
}
|
|
30
|
+
MajorityNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
31
|
+
var patterns = insightInfo.patterns, data = insightInfo.data;
|
|
32
|
+
var _a = patterns[0], dimension = _a.dimension, measure = _a.measure, x = _a.x, y = _a.y;
|
|
33
|
+
var total = (0, lodash_1.sumBy)(data, measure);
|
|
34
|
+
var spec = (0, ntv_1.generateTextSpec)({
|
|
35
|
+
structures: MajorityNarrativeStrategy.structures[lang],
|
|
36
|
+
variable: {
|
|
37
|
+
dimension: dimension,
|
|
38
|
+
measure: measure,
|
|
39
|
+
dimValue: x,
|
|
40
|
+
y: y,
|
|
41
|
+
total: total,
|
|
42
|
+
proportion: y / total,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return spec.sections[0].paragraphs;
|
|
46
|
+
};
|
|
47
|
+
MajorityNarrativeStrategy.insightType = 'majority';
|
|
48
|
+
MajorityNarrativeStrategy.structures = {
|
|
49
|
+
'zh-CN': [
|
|
50
|
+
{
|
|
51
|
+
template: '按照 ${dimension} 对 ${measure} 进行拆解,${dimValue} 的 ${measure} 显著高于其他维值,为 ${y}, 占总数(${total})的 ${proportion}。',
|
|
52
|
+
variableMetaMap: variableMetaMap,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
'en-US': [
|
|
56
|
+
{
|
|
57
|
+
template: 'Breaking down the ${measure} by ${dimension}, the ${measure} for ${dimValue} is significantly higher than the other dimensions, at ${y}, ${proportion} of the total (${total}).',
|
|
58
|
+
variableMetaMap: variableMetaMap,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
return MajorityNarrativeStrategy;
|
|
63
|
+
}(base_1.InsightNarrativeStrategy));
|
|
64
|
+
exports.default = MajorityNarrativeStrategy;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightNarrativeStrategy } from './base';
|
|
2
|
+
import type { InsightType, Language, InsightInfo, TimeSeriesOutlierInfo } from '../../types';
|
|
3
|
+
import type { ParagraphSpec, Structure } from '../../../ntv/types';
|
|
4
|
+
export default class TimeSeriesOutlierNarrativeStrategy extends InsightNarrativeStrategy<TimeSeriesOutlierInfo> {
|
|
5
|
+
static readonly insightType: InsightType;
|
|
6
|
+
protected static structures: Record<Language, Structure[]>;
|
|
7
|
+
generateTextSpec(insightInfo: InsightInfo<TimeSeriesOutlierInfo>, lang: Language): ParagraphSpec[];
|
|
8
|
+
}
|