@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,55 @@
|
|
|
1
|
+
import { get, isNil, isString } from 'lodash';
|
|
2
|
+
import { changePoint } from '../../algorithms';
|
|
3
|
+
import { getAlgorithmCommonInput, getNonSignificantInsight, preValidation } from '../util';
|
|
4
|
+
import { CHANGE_POINT_SIGNIFICANCE_BENCHMARK } from '../../constant';
|
|
5
|
+
export var findChangePoints = function (series, changePointsParameter) {
|
|
6
|
+
var _a;
|
|
7
|
+
var results = changePoint.Bayesian(series);
|
|
8
|
+
var changePointsResult = [];
|
|
9
|
+
// significanceBenchmark is equivalent to the confidence interval in hypothesis testing
|
|
10
|
+
var significanceBenchmark = 1 - ((_a = changePointsParameter === null || changePointsParameter === void 0 ? void 0 : changePointsParameter.threshold) !== null && _a !== void 0 ? _a : CHANGE_POINT_SIGNIFICANCE_BENCHMARK);
|
|
11
|
+
results.forEach(function (item) {
|
|
12
|
+
// item.significance is similar to confidence interval
|
|
13
|
+
if ((item === null || item === void 0 ? void 0 : item.index) >= 0 && (item === null || item === void 0 ? void 0 : item.significance) >= significanceBenchmark) {
|
|
14
|
+
changePointsResult.push(item);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return changePointsResult;
|
|
18
|
+
};
|
|
19
|
+
export var getChangePointInfo = function (props) {
|
|
20
|
+
var valid = preValidation(props);
|
|
21
|
+
var insightType = 'change_point';
|
|
22
|
+
if (isString(valid))
|
|
23
|
+
return getNonSignificantInsight({ detailInfo: valid, insightType: insightType, infoType: 'verificationFailure' });
|
|
24
|
+
var data = props.data;
|
|
25
|
+
var _a = getAlgorithmCommonInput(props), dimension = _a.dimension, values = _a.values, measure = _a.measure;
|
|
26
|
+
if (isNil(dimension) || isNil(measure))
|
|
27
|
+
return getNonSignificantInsight({
|
|
28
|
+
detailInfo: 'Measure or dimension is empty.',
|
|
29
|
+
insightType: insightType,
|
|
30
|
+
infoType: 'verificationFailure',
|
|
31
|
+
});
|
|
32
|
+
var changePointsParameter = get(props, 'options.algorithmParameter.changePoint');
|
|
33
|
+
var changePoints = findChangePoints(values, changePointsParameter);
|
|
34
|
+
if (changePoints.length === 0) {
|
|
35
|
+
var info = 'Bayesian Online Changepoint Detection does not pass.';
|
|
36
|
+
return getNonSignificantInsight({ insightType: insightType, infoType: 'noInsight', customInfo: { info: info } });
|
|
37
|
+
}
|
|
38
|
+
var outliers = [];
|
|
39
|
+
changePoints.forEach(function (item) {
|
|
40
|
+
var index = item.index, significance = item.significance;
|
|
41
|
+
if (!isNil(data[index])) {
|
|
42
|
+
outliers.push({
|
|
43
|
+
type: insightType,
|
|
44
|
+
dimension: dimension,
|
|
45
|
+
measure: measure,
|
|
46
|
+
significance: significance,
|
|
47
|
+
index: index,
|
|
48
|
+
x: data[index][dimension],
|
|
49
|
+
y: data[index][measure],
|
|
50
|
+
significantInsight: true,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return outliers;
|
|
55
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { isString } from 'lodash';
|
|
3
|
+
import { pcorrtest } from '../../../data';
|
|
4
|
+
import { getNonSignificantInsight, preValidation } from '../util';
|
|
5
|
+
import { DEFAULT_PCORRTEST_OPTIONS } from '../../../data/statistics/constants';
|
|
6
|
+
export function findCorrelation(x, y, pCorrTestParameter) {
|
|
7
|
+
var testResult = pcorrtest(x, y, pCorrTestParameter);
|
|
8
|
+
// @ts-ignore Type Result is missing the "pcorr"
|
|
9
|
+
var rejected = testResult.rejected, pcorr = testResult.pcorr;
|
|
10
|
+
if (rejected) {
|
|
11
|
+
return {
|
|
12
|
+
pcorr: pcorr,
|
|
13
|
+
significance: Math.abs(pcorr),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export var getCorrelationInfo = function (props) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var valid = preValidation(props);
|
|
21
|
+
var insightType = 'correlation';
|
|
22
|
+
var data = props.data, measures = props.measures, dimensions = props.dimensions, options = props.options;
|
|
23
|
+
if (isString(valid) || !dimensions)
|
|
24
|
+
return getNonSignificantInsight(__assign({ insightType: insightType, infoType: 'verificationFailure' }, (isString(valid) ? { detailInfo: valid } : {})));
|
|
25
|
+
var xField = measures[0].fieldName;
|
|
26
|
+
var yField = measures[1].fieldName;
|
|
27
|
+
var x = data.map(function (item) { return item === null || item === void 0 ? void 0 : item[xField]; });
|
|
28
|
+
var y = data.map(function (item) { return item === null || item === void 0 ? void 0 : item[yField]; });
|
|
29
|
+
var correlationParameter = (_a = options === null || options === void 0 ? void 0 : options.algorithmParameter) === null || _a === void 0 ? void 0 : _a.correlation;
|
|
30
|
+
var result = findCorrelation(x, y, correlationParameter);
|
|
31
|
+
if (result) {
|
|
32
|
+
return [
|
|
33
|
+
__assign(__assign({}, result), { type: insightType, measures: [xField, yField], significantInsight: true }),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
var info = "The Pearson product-moment correlation test does not pass at the specified significance level ".concat((_b = correlationParameter === null || correlationParameter === void 0 ? void 0 : correlationParameter.alpha) !== null && _b !== void 0 ? _b : DEFAULT_PCORRTEST_OPTIONS.alpha, ".");
|
|
37
|
+
return getNonSignificantInsight({ insightType: insightType, infoType: 'noInsight', customInfo: { info: info } });
|
|
38
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { groupBy, flatten } from 'lodash';
|
|
3
|
+
import { PATTERN_TYPES } from '../../constant';
|
|
4
|
+
/**
|
|
5
|
+
* homogeneous data pattern (HDP) represents a set of basic data patterns that share certain relations. HDP are identified by categorizing basic data patterns (within an HDP) into commonness(es) and exceptions considering inter-pattern similarity,
|
|
6
|
+
*/
|
|
7
|
+
function extractHomogeneousPatterns(collection, type) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
var homogeneousPatterns = [];
|
|
10
|
+
var scopeLength = collection.length;
|
|
11
|
+
var validScopes = collection.filter(function (item) { var _a; return item.patterns && ((_a = item.patterns) === null || _a === void 0 ? void 0 : _a.length) > 0; });
|
|
12
|
+
if (validScopes.length > 1) {
|
|
13
|
+
if (type === 'trend') {
|
|
14
|
+
var parts = Object.values(groupBy(collection, 'patterns.0.trend')).sort(function (a, b) { return b.length - a.length; });
|
|
15
|
+
if (parts.length === 2 &&
|
|
16
|
+
((_b = (_a = parts[0][0]) === null || _a === void 0 ? void 0 : _a.patterns) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
17
|
+
parts[0].length / scopeLength > 0.75 &&
|
|
18
|
+
parts[1].length < 5) {
|
|
19
|
+
homogeneousPatterns.push({
|
|
20
|
+
type: 'exception',
|
|
21
|
+
insightType: type,
|
|
22
|
+
childPatterns: flatten(validScopes.map(function (item) { return item.patterns; })),
|
|
23
|
+
commonSet: parts[0].map(function (item) { return item.key; }),
|
|
24
|
+
exceptions: parts[1].map(function (item) { return item.key; }),
|
|
25
|
+
significance: 1 - parts[1].length / scopeLength,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
parts.forEach(function (part) {
|
|
30
|
+
var _a;
|
|
31
|
+
var ratio = part.length / scopeLength;
|
|
32
|
+
if (ratio > 0.3 && part.length >= 3 && ((_a = part[0]) === null || _a === void 0 ? void 0 : _a.patterns)) {
|
|
33
|
+
var childPatterns = flatten(part.map(function (item) { return item.patterns; }));
|
|
34
|
+
if (childPatterns.length) {
|
|
35
|
+
homogeneousPatterns.push({
|
|
36
|
+
type: 'commonness',
|
|
37
|
+
insightType: type,
|
|
38
|
+
childPatterns: childPatterns,
|
|
39
|
+
commonSet: part.map(function (item) { return item.key; }),
|
|
40
|
+
significance: ratio,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (['change_point', 'outlier', 'time_series_outlier'].includes(type)) {
|
|
48
|
+
var commonSetIndexes = Object.values(groupBy(flatten(validScopes.map(function (item) { return item.patterns.map(function (item) { return item.index; }); })))).sort(function (a, b) { return b.length - a.length; });
|
|
49
|
+
commonSetIndexes.forEach(function (indexArr) {
|
|
50
|
+
var ratio = indexArr.length / scopeLength;
|
|
51
|
+
if (ratio > 0.3 && indexArr.length >= 3) {
|
|
52
|
+
var scopes = validScopes.filter(function (item) {
|
|
53
|
+
return item.patterns.some(function (item) { return item.index === indexArr[0]; });
|
|
54
|
+
});
|
|
55
|
+
var childPatterns = flatten(scopes.map(function (item) { return item.patterns.filter(function (item) { return item.index === indexArr[0]; }); }));
|
|
56
|
+
homogeneousPatterns.push({
|
|
57
|
+
type: 'commonness',
|
|
58
|
+
insightType: type,
|
|
59
|
+
childPatterns: childPatterns,
|
|
60
|
+
commonSet: scopes.map(function (item) { return item.key; }),
|
|
61
|
+
significance: ratio,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return homogeneousPatterns;
|
|
68
|
+
}
|
|
69
|
+
export function extractHomogeneousPatternsForMeasures(measures, insightsCollection) {
|
|
70
|
+
var series = measures.map(function (item) { return item.fieldName; });
|
|
71
|
+
var patternsForAllMeasures = insightsCollection.map(function (item) { return item === null || item === void 0 ? void 0 : item.patterns; });
|
|
72
|
+
var homogeneousPatterns = [];
|
|
73
|
+
PATTERN_TYPES.forEach(function (type) {
|
|
74
|
+
var patternCollection = patternsForAllMeasures.map(function (item, index) { return ({
|
|
75
|
+
key: series[index],
|
|
76
|
+
patterns: item === null || item === void 0 ? void 0 : item.filter(function (item) { return item.type === type; }),
|
|
77
|
+
}); });
|
|
78
|
+
var patterns = extractHomogeneousPatterns(patternCollection, type);
|
|
79
|
+
homogeneousPatterns.push.apply(homogeneousPatterns, __spreadArray([], __read(patterns), false));
|
|
80
|
+
});
|
|
81
|
+
return homogeneousPatterns;
|
|
82
|
+
}
|
|
83
|
+
export function extractHomogeneousPatternsForSiblingGroups(siblingItems, insightsCollection) {
|
|
84
|
+
var groupLength = insightsCollection.length;
|
|
85
|
+
if (siblingItems.length !== groupLength)
|
|
86
|
+
return [];
|
|
87
|
+
var patternsForSiblingGroup = insightsCollection.map(function (item) { return item === null || item === void 0 ? void 0 : item.patterns; });
|
|
88
|
+
var homogeneousPatterns = [];
|
|
89
|
+
PATTERN_TYPES.forEach(function (type) {
|
|
90
|
+
var patternCollection = patternsForSiblingGroup.map(function (arr, index) { return ({
|
|
91
|
+
key: siblingItems[index],
|
|
92
|
+
patterns: arr === null || arr === void 0 ? void 0 : arr.filter(function (item) { return item.type === type; }),
|
|
93
|
+
}); });
|
|
94
|
+
var patterns = extractHomogeneousPatterns(patternCollection, type);
|
|
95
|
+
homogeneousPatterns.push.apply(homogeneousPatterns, __spreadArray([], __read(patterns), false));
|
|
96
|
+
});
|
|
97
|
+
return homogeneousPatterns;
|
|
98
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { get, isNil, isString } from 'lodash';
|
|
2
|
+
import { coefficientOfVariance, mean } from '../../../data';
|
|
3
|
+
import { getAlgorithmCommonInput, getNonSignificantInsight, preValidation } from '../util';
|
|
4
|
+
// Coefficient of variation threshold
|
|
5
|
+
var CV_THRESHOLD = 0.15;
|
|
6
|
+
export function findLowVariance(values, lowVarianceParameter) {
|
|
7
|
+
var cv = coefficientOfVariance(values);
|
|
8
|
+
var cvThreshold = (lowVarianceParameter === null || lowVarianceParameter === void 0 ? void 0 : lowVarianceParameter.cvThreshold) || CV_THRESHOLD;
|
|
9
|
+
if (cv >= cvThreshold) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
// The smaller the CV is, the greater the significance is.
|
|
13
|
+
var significance = 1 - cv;
|
|
14
|
+
var meanValue = mean(values);
|
|
15
|
+
return {
|
|
16
|
+
significance: significance,
|
|
17
|
+
mean: meanValue,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export var getLowVarianceInfo = function (props) {
|
|
21
|
+
var valid = preValidation(props);
|
|
22
|
+
var insightType = 'low_variance';
|
|
23
|
+
if (isString(valid))
|
|
24
|
+
return getNonSignificantInsight({ detailInfo: valid, insightType: insightType, infoType: 'verificationFailure' });
|
|
25
|
+
var _a = getAlgorithmCommonInput(props), dimension = _a.dimension, values = _a.values, measure = _a.measure;
|
|
26
|
+
if (isNil(dimension) || isNil(measure))
|
|
27
|
+
return getNonSignificantInsight({
|
|
28
|
+
detailInfo: 'Measure or dimension is empty.',
|
|
29
|
+
insightType: insightType,
|
|
30
|
+
infoType: 'verificationFailure',
|
|
31
|
+
});
|
|
32
|
+
var lowVarianceParameter = get(props, 'options.algorithmParameter.lowVariance');
|
|
33
|
+
var lowVariance = findLowVariance(values, lowVarianceParameter);
|
|
34
|
+
if (lowVariance) {
|
|
35
|
+
var significance = lowVariance.significance, mean_1 = lowVariance.mean;
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
type: insightType,
|
|
39
|
+
dimension: dimension,
|
|
40
|
+
measure: measure,
|
|
41
|
+
significance: significance,
|
|
42
|
+
mean: mean_1,
|
|
43
|
+
significantInsight: true,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
var info = "The coefficient of variance of the data is greater than ".concat((lowVarianceParameter === null || lowVarianceParameter === void 0 ? void 0 : lowVarianceParameter.cvThreshold) || CV_THRESHOLD, ". The data does not follow a uniform distribution.");
|
|
48
|
+
return getNonSignificantInsight({ insightType: insightType, infoType: 'noInsight', customInfo: { info: info } });
|
|
49
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { get, isNil, isString } from 'lodash';
|
|
2
|
+
import { getAlgorithmCommonInput, getNonSignificantInsight, preValidation } from '../util';
|
|
3
|
+
var DEFAULT_PROPORTION_LIMIT = 0.6;
|
|
4
|
+
export function findMajority(values, majorityParameter) {
|
|
5
|
+
var sum = 0;
|
|
6
|
+
var max = -Infinity;
|
|
7
|
+
var maxIndex = -1;
|
|
8
|
+
for (var i = 0; i < (values === null || values === void 0 ? void 0 : values.length); i += 1) {
|
|
9
|
+
sum += values[i];
|
|
10
|
+
if (values[i] > max) {
|
|
11
|
+
max = values[i];
|
|
12
|
+
maxIndex = i;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var proportionLimit = (majorityParameter === null || majorityParameter === void 0 ? void 0 : majorityParameter.limit) || DEFAULT_PROPORTION_LIMIT;
|
|
16
|
+
if (sum === 0)
|
|
17
|
+
return null;
|
|
18
|
+
var proportion = max / sum;
|
|
19
|
+
if (proportion > proportionLimit && proportion < 1) {
|
|
20
|
+
return {
|
|
21
|
+
index: maxIndex,
|
|
22
|
+
value: max,
|
|
23
|
+
proportion: proportion,
|
|
24
|
+
significance: proportion,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
export var getMajorityInfo = function (props) {
|
|
30
|
+
var valid = preValidation(props);
|
|
31
|
+
var insightType = 'majority';
|
|
32
|
+
if (isString(valid))
|
|
33
|
+
return getNonSignificantInsight({ detailInfo: valid, insightType: insightType, infoType: 'verificationFailure' });
|
|
34
|
+
var data = props.data;
|
|
35
|
+
var _a = getAlgorithmCommonInput(props), dimension = _a.dimension, values = _a.values, measure = _a.measure;
|
|
36
|
+
if (isNil(dimension) || isNil(measure))
|
|
37
|
+
return getNonSignificantInsight({
|
|
38
|
+
detailInfo: 'Measure or dimension is empty.',
|
|
39
|
+
insightType: insightType,
|
|
40
|
+
infoType: 'verificationFailure',
|
|
41
|
+
});
|
|
42
|
+
var majorityParameter = get(props, 'options.algorithmParameter.majority');
|
|
43
|
+
var majority = findMajority(values, majorityParameter);
|
|
44
|
+
if (majority) {
|
|
45
|
+
var significance = majority.significance, index = majority.index, proportion = majority.proportion;
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
type: insightType,
|
|
49
|
+
dimension: dimension,
|
|
50
|
+
measure: measure,
|
|
51
|
+
significance: significance,
|
|
52
|
+
index: index,
|
|
53
|
+
proportion: proportion,
|
|
54
|
+
x: data[index][dimension],
|
|
55
|
+
y: data[index][measure],
|
|
56
|
+
significantInsight: true,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
var info = "After disassembling with the given dimension, the proportion of the maximum value does not exceed ".concat((majorityParameter === null || majorityParameter === void 0 ? void 0 : majorityParameter.limit) || DEFAULT_PROPORTION_LIMIT, ".");
|
|
61
|
+
return getNonSignificantInsight({
|
|
62
|
+
insightType: insightType,
|
|
63
|
+
infoType: 'noInsight',
|
|
64
|
+
customInfo: { info: info, dimension: dimension, measure: measure },
|
|
65
|
+
});
|
|
66
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { get, isNil, isString } from 'lodash';
|
|
2
|
+
import { distinct, lowess } from '../../../data';
|
|
3
|
+
import { LOWESS_N_STEPS } from '../../constant';
|
|
4
|
+
import { getAlgorithmCommonInput, getNonSignificantInsight, preValidation } from '../util';
|
|
5
|
+
import { findOutliers } from './categoryOutlier';
|
|
6
|
+
// detect the outliers using LOWESS
|
|
7
|
+
function findTimeSeriesOutliers(values, outlierParameter) {
|
|
8
|
+
var indexes = Array(values.length)
|
|
9
|
+
.fill(0)
|
|
10
|
+
.map(function (_, index) { return index; });
|
|
11
|
+
var baseline = lowess(indexes, values, { nSteps: LOWESS_N_STEPS });
|
|
12
|
+
var residuals = values.map(function (item, index) { return item - baseline.y[index]; });
|
|
13
|
+
var _a = findOutliers(residuals, outlierParameter), outliers = _a.outliers, thresholds = _a.thresholds;
|
|
14
|
+
return { outliers: outliers, baselines: baseline.y, thresholds: thresholds };
|
|
15
|
+
}
|
|
16
|
+
export var getTimeSeriesOutlierInfo = function (props) {
|
|
17
|
+
var valid = preValidation(props);
|
|
18
|
+
var insightType = 'time_series_outlier';
|
|
19
|
+
if (isString(valid))
|
|
20
|
+
return getNonSignificantInsight({ detailInfo: valid, insightType: insightType, infoType: 'verificationFailure' });
|
|
21
|
+
var data = props.data;
|
|
22
|
+
var _a = getAlgorithmCommonInput(props), dimension = _a.dimension, values = _a.values, measure = _a.measure;
|
|
23
|
+
if (isNil(dimension) || isNil(measure))
|
|
24
|
+
return getNonSignificantInsight({
|
|
25
|
+
detailInfo: 'Measure or dimension is empty.',
|
|
26
|
+
insightType: insightType,
|
|
27
|
+
infoType: 'verificationFailure',
|
|
28
|
+
});
|
|
29
|
+
if (distinct(values) === 1)
|
|
30
|
+
return getNonSignificantInsight({ insightType: insightType, infoType: 'noInsight' });
|
|
31
|
+
var outlierParameter = get(props, 'options.algorithmParameter.outlier');
|
|
32
|
+
var _b = findTimeSeriesOutliers(values, outlierParameter), outliers = _b.outliers, baselines = _b.baselines, thresholds = _b.thresholds;
|
|
33
|
+
if (outliers.length === 0)
|
|
34
|
+
return getNonSignificantInsight({
|
|
35
|
+
insightType: insightType,
|
|
36
|
+
infoType: 'noInsight',
|
|
37
|
+
customInfo: {
|
|
38
|
+
baselines: baselines,
|
|
39
|
+
thresholds: thresholds,
|
|
40
|
+
dimension: dimension,
|
|
41
|
+
measure: measure,
|
|
42
|
+
info: 'No outliers were found.',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
var timeSeriesOutliers = outliers.map(function (item) {
|
|
46
|
+
var index = item.index, significance = item.significance;
|
|
47
|
+
return {
|
|
48
|
+
type: insightType,
|
|
49
|
+
dimension: dimension,
|
|
50
|
+
measure: measure,
|
|
51
|
+
significance: significance,
|
|
52
|
+
index: index,
|
|
53
|
+
x: data[index][dimension],
|
|
54
|
+
y: data[index][measure],
|
|
55
|
+
baselines: baselines,
|
|
56
|
+
thresholds: thresholds,
|
|
57
|
+
significantInsight: true,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
return timeSeriesOutliers;
|
|
61
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import regression from 'regression';
|
|
3
|
+
import { get, isNil, isString } from 'lodash';
|
|
4
|
+
import { trendDirection } from '../../algorithms';
|
|
5
|
+
import { getAlgorithmCommonInput, getNonSignificantInsight, preValidation } from '../util';
|
|
6
|
+
import { SIGNIFICANCE_LEVEL } from '../../constant';
|
|
7
|
+
export function findTimeSeriesTrend(series, trendParameter) {
|
|
8
|
+
var _a;
|
|
9
|
+
var significance = (_a = trendParameter === null || trendParameter === void 0 ? void 0 : trendParameter.threshold) !== null && _a !== void 0 ? _a : SIGNIFICANCE_LEVEL;
|
|
10
|
+
var testResult = trendDirection.mkTest(series, significance);
|
|
11
|
+
var pValue = testResult.pValue, trend = testResult.trend;
|
|
12
|
+
var regressionResult = regression.linear(series.map(function (item, index) { return [index, item]; }));
|
|
13
|
+
var r2 = regressionResult.r2, points = regressionResult.points, equation = regressionResult.equation;
|
|
14
|
+
return {
|
|
15
|
+
trend: trend,
|
|
16
|
+
significance: 1 - pValue,
|
|
17
|
+
regression: {
|
|
18
|
+
r2: r2,
|
|
19
|
+
points: points.map(function (item) { return item[1]; }),
|
|
20
|
+
equation: equation,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export var getTrendInfo = function (props) {
|
|
25
|
+
var _a;
|
|
26
|
+
var valid = preValidation(props);
|
|
27
|
+
var insightType = 'trend';
|
|
28
|
+
if (isString(valid))
|
|
29
|
+
return getNonSignificantInsight({ detailInfo: valid, insightType: insightType, infoType: 'verificationFailure' });
|
|
30
|
+
var _b = getAlgorithmCommonInput(props), dimension = _b.dimension, values = _b.values, measure = _b.measure;
|
|
31
|
+
if (isNil(dimension) || isNil(measure))
|
|
32
|
+
return getNonSignificantInsight({
|
|
33
|
+
detailInfo: 'Measure or dimension is empty.',
|
|
34
|
+
insightType: insightType,
|
|
35
|
+
infoType: 'verificationFailure',
|
|
36
|
+
});
|
|
37
|
+
var trendParameter = get(props, 'options.algorithmParameter.trend');
|
|
38
|
+
var result = findTimeSeriesTrend(values, trendParameter);
|
|
39
|
+
return [
|
|
40
|
+
__assign(__assign(__assign({}, result), { type: 'trend', dimension: dimension, measure: measure }), (result.trend === 'no trend'
|
|
41
|
+
? {
|
|
42
|
+
significantInsight: false,
|
|
43
|
+
info: "The Mann-Kendall (MK) test does not pass at the specified significance level ".concat((_a = trendParameter === null || trendParameter === void 0 ? void 0 : trendParameter.threshold) !== null && _a !== void 0 ? _a : SIGNIFICANCE_LEVEL, "."),
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
significantInsight: true,
|
|
47
|
+
})),
|
|
48
|
+
];
|
|
49
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { flow, isFunction } from 'lodash';
|
|
3
|
+
import { getCategoryOutlierInfo } from './extractors/categoryOutlier';
|
|
4
|
+
import { getChangePointInfo } from './extractors/changePoint';
|
|
5
|
+
import { getCorrelationInfo } from './extractors/correlation';
|
|
6
|
+
import { getLowVarianceInfo } from './extractors/lowVariance';
|
|
7
|
+
import { getMajorityInfo } from './extractors/majority';
|
|
8
|
+
import { getTimeSeriesOutlierInfo } from './extractors/timeSeriesOutlier';
|
|
9
|
+
import { getTrendInfo } from './extractors/trend';
|
|
10
|
+
import { pickValidPattern } from './util';
|
|
11
|
+
export var extractorMap = {
|
|
12
|
+
category_outlier: getCategoryOutlierInfo,
|
|
13
|
+
trend: getTrendInfo,
|
|
14
|
+
change_point: getChangePointInfo,
|
|
15
|
+
time_series_outlier: getTimeSeriesOutlierInfo,
|
|
16
|
+
majority: getMajorityInfo,
|
|
17
|
+
low_variance: getLowVarianceInfo,
|
|
18
|
+
correlation: getCorrelationInfo,
|
|
19
|
+
};
|
|
20
|
+
export var insightPatternsExtractor = function (props) {
|
|
21
|
+
var _a = props.insightType, insightType = _a === void 0 ? 'trend' : _a, options = props.options;
|
|
22
|
+
var _b = (options || {}).filterInsight, filterInsight = _b === void 0 ? false : _b;
|
|
23
|
+
var extractor = extractorMap[insightType];
|
|
24
|
+
if (!isFunction(extractor))
|
|
25
|
+
return [];
|
|
26
|
+
return flow(__spreadArray([extractor], __read((filterInsight ? [pickValidPattern] : [])), false))(props);
|
|
27
|
+
};
|
|
28
|
+
export * from './checkers';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { isNil, mean } from 'lodash';
|
|
3
|
+
import { standardDeviation, cdf, normalDistributionQuantile, max, min } from '../../data';
|
|
4
|
+
import { dataToDataProps } from '../pipeline/preprocess';
|
|
5
|
+
import { NO_PATTERN_INFO, VERIFICATION_FAILURE_INFO } from '../constant';
|
|
6
|
+
import { ExtractorCheckers } from './checkers';
|
|
7
|
+
export var calculatePValue = function (values, target, alternative) {
|
|
8
|
+
if (alternative === void 0) { alternative = 'two-sided'; }
|
|
9
|
+
var meanValue = mean(values);
|
|
10
|
+
var std = standardDeviation(values);
|
|
11
|
+
var cdfValue = cdf(target, meanValue, std);
|
|
12
|
+
if (alternative === 'two-sided')
|
|
13
|
+
return cdfValue < 0.5 ? 2 * cdfValue : 2 * (1 - cdfValue);
|
|
14
|
+
if (alternative === 'less')
|
|
15
|
+
return cdfValue;
|
|
16
|
+
return 1 - cdfValue;
|
|
17
|
+
};
|
|
18
|
+
export var calculateOutlierThresholds = function (values, significance, alternative) {
|
|
19
|
+
if (alternative === void 0) { alternative = 'two-sided'; }
|
|
20
|
+
var meanValue = mean(values);
|
|
21
|
+
var std = standardDeviation(values);
|
|
22
|
+
var p = 1 - significance;
|
|
23
|
+
if (alternative === 'greater')
|
|
24
|
+
return [normalDistributionQuantile(significance, meanValue, std), max(values)];
|
|
25
|
+
if (alternative === 'less')
|
|
26
|
+
return [min(values), normalDistributionQuantile(p, meanValue, std)];
|
|
27
|
+
return [
|
|
28
|
+
normalDistributionQuantile(p / 2, meanValue, std),
|
|
29
|
+
normalDistributionQuantile(significance + p / 2, meanValue, std),
|
|
30
|
+
];
|
|
31
|
+
};
|
|
32
|
+
export var getAlgorithmCommonInput = function (_a) {
|
|
33
|
+
var _b, _c;
|
|
34
|
+
var data = _a.data, dimensions = _a.dimensions, measures = _a.measures;
|
|
35
|
+
var dimension = (_b = dimensions === null || dimensions === void 0 ? void 0 : dimensions[0]) === null || _b === void 0 ? void 0 : _b.fieldName;
|
|
36
|
+
var measure = (_c = measures === null || measures === void 0 ? void 0 : measures[0]) === null || _c === void 0 ? void 0 : _c.fieldName;
|
|
37
|
+
var values = data.map(function (item) { return Number(item === null || item === void 0 ? void 0 : item[measure]); });
|
|
38
|
+
return { dimension: dimension, measure: measure, values: values };
|
|
39
|
+
};
|
|
40
|
+
export var preValidation = function (_a) {
|
|
41
|
+
var data = _a.data, dimensions = _a.dimensions, measures = _a.measures, options = _a.options, insightType = _a.insightType;
|
|
42
|
+
var _b = options || {}, _c = _b.dataValidation, dataValidation = _c === void 0 ? false : _c, dataProcessInfo = _b.dataProcessInfo;
|
|
43
|
+
if (!data || data.length === 0)
|
|
44
|
+
return 'No data. ';
|
|
45
|
+
if (!dataValidation)
|
|
46
|
+
return true;
|
|
47
|
+
var filteredData = data.filter(function (item) { return !Object.values(item).some(function (v) { return v === null || v === undefined; }); });
|
|
48
|
+
var dataProps = dataToDataProps(filteredData, dataProcessInfo);
|
|
49
|
+
var fieldPropsMap = dataProps.reduce(function (acc, item) {
|
|
50
|
+
acc[item.name] = item;
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
53
|
+
var checker = ExtractorCheckers[insightType];
|
|
54
|
+
if (!checker)
|
|
55
|
+
return true;
|
|
56
|
+
var result = checker({
|
|
57
|
+
data: data,
|
|
58
|
+
subjectInfo: { dimensions: dimensions === null || dimensions === void 0 ? void 0 : dimensions.map(function (dim) { return dim.fieldName; }), measures: measures, subspace: [] },
|
|
59
|
+
fieldPropsMap: fieldPropsMap,
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
export var getNonSignificantInsight = function (_a) {
|
|
64
|
+
var infoType = _a.infoType, insightType = _a.insightType, _b = _a.detailInfo, detailInfo = _b === void 0 ? '' : _b, _c = _a.customInfo, customInfo = _c === void 0 ? {} : _c;
|
|
65
|
+
var info = "".concat(detailInfo).concat(infoType === 'noInsight' ? NO_PATTERN_INFO : VERIFICATION_FAILURE_INFO);
|
|
66
|
+
return [
|
|
67
|
+
__assign({ significantInsight: false, type: insightType, info: info, significance: 0 }, customInfo),
|
|
68
|
+
];
|
|
69
|
+
};
|
|
70
|
+
export var pickValidPattern = function (infos) {
|
|
71
|
+
if (infos === void 0) { infos = []; }
|
|
72
|
+
return infos.filter(function (info) { return info.significantInsight; });
|
|
73
|
+
};
|
|
74
|
+
export var pickValidTimeSeriesOutlierPatterns = function (infos) {
|
|
75
|
+
if (infos === void 0) { infos = []; }
|
|
76
|
+
return infos.filter(function (info) { return ![info.baselines, info.thresholds, info.x].every(isNil); });
|
|
77
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var _this = this;
|
|
2
|
+
import * as insightNarrativeStrategies from './strategy';
|
|
3
|
+
var InsightNarrativeStrategyFactory = /** @class */ (function () {
|
|
4
|
+
function InsightNarrativeStrategyFactory() {
|
|
5
|
+
}
|
|
6
|
+
InsightNarrativeStrategyFactory.getStrategy = function (type) {
|
|
7
|
+
var strategy = InsightNarrativeStrategyFactory.narrativeStrategyMap.get(type);
|
|
8
|
+
if (!strategy)
|
|
9
|
+
throw Error("There is no description policy for this '".concat(type, "'."));
|
|
10
|
+
return strategy;
|
|
11
|
+
};
|
|
12
|
+
var _a;
|
|
13
|
+
_a = InsightNarrativeStrategyFactory;
|
|
14
|
+
InsightNarrativeStrategyFactory.narrativeStrategyMap = new Map();
|
|
15
|
+
(function () {
|
|
16
|
+
Object.values(insightNarrativeStrategies).forEach(function (Strategy) {
|
|
17
|
+
_a.narrativeStrategyMap.set(Strategy.insightType, new Strategy());
|
|
18
|
+
});
|
|
19
|
+
})();
|
|
20
|
+
return InsightNarrativeStrategyFactory;
|
|
21
|
+
}());
|
|
22
|
+
export default InsightNarrativeStrategyFactory;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import InsightNarrativeStrategyFactory from './factory';
|
|
2
|
+
function isHomogeneousPattern(insightInfo) {
|
|
3
|
+
return 'childPatterns' in insightInfo;
|
|
4
|
+
}
|
|
5
|
+
export default function generateInsightNarrative(insightInfo, options) {
|
|
6
|
+
var _a;
|
|
7
|
+
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;
|
|
8
|
+
if (!insightType)
|
|
9
|
+
throw Error('insight info has no insight type');
|
|
10
|
+
var lang = options.lang;
|
|
11
|
+
var strategy = InsightNarrativeStrategyFactory.getStrategy(insightType);
|
|
12
|
+
var result = strategy.generateTextSpec(insightInfo, lang);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
/* eslint-disable no-template-curly-in-string */
|
|
3
|
+
import { generateTextSpec } from '../../../ntv';
|
|
4
|
+
import { InsightNarrativeStrategy } from './base';
|
|
5
|
+
import { getDefaultSeparator } from './helpers';
|
|
6
|
+
var variableMetaMap = {
|
|
7
|
+
measure: {
|
|
8
|
+
varType: 'metric_name',
|
|
9
|
+
},
|
|
10
|
+
total: {
|
|
11
|
+
varType: 'metric_value',
|
|
12
|
+
},
|
|
13
|
+
'.x': {
|
|
14
|
+
varType: 'dim_value',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
var CategoryOutlierNarrativeStrategy = /** @class */ (function (_super) {
|
|
18
|
+
__extends(CategoryOutlierNarrativeStrategy, _super);
|
|
19
|
+
function CategoryOutlierNarrativeStrategy() {
|
|
20
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
CategoryOutlierNarrativeStrategy.prototype.generateTextSpec = function (insightInfo, lang) {
|
|
23
|
+
var patterns = insightInfo.patterns;
|
|
24
|
+
var _a = patterns[0], dimension = _a.dimension, measure = _a.measure;
|
|
25
|
+
var spec = generateTextSpec({
|
|
26
|
+
structures: CategoryOutlierNarrativeStrategy.structures[lang],
|
|
27
|
+
variable: {
|
|
28
|
+
dimension: dimension,
|
|
29
|
+
measure: measure,
|
|
30
|
+
total: patterns.length,
|
|
31
|
+
patterns: patterns,
|
|
32
|
+
},
|
|
33
|
+
structureTemps: CategoryOutlierNarrativeStrategy.structureTemps[lang],
|
|
34
|
+
});
|
|
35
|
+
return spec.sections[0].paragraphs;
|
|
36
|
+
};
|
|
37
|
+
CategoryOutlierNarrativeStrategy.insightType = 'category_outlier';
|
|
38
|
+
CategoryOutlierNarrativeStrategy.structures = {
|
|
39
|
+
'zh-CN': [
|
|
40
|
+
{
|
|
41
|
+
template: '${measure} 在 ${dimension} 上有 ${total} 个类别相比其他维值突出:&{outliers}。',
|
|
42
|
+
variableMetaMap: variableMetaMap,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
'en-US': [
|
|
46
|
+
{
|
|
47
|
+
template: '${measure} has ${total} categories in the ${dimension} that are prominent compared to other dimensions: &{outliers}.',
|
|
48
|
+
variableMetaMap: variableMetaMap,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
CategoryOutlierNarrativeStrategy.structureTemps = {
|
|
53
|
+
'zh-CN': [
|
|
54
|
+
{
|
|
55
|
+
templateId: 'outliers',
|
|
56
|
+
template: '${.x}',
|
|
57
|
+
separator: getDefaultSeparator('zh-CN'),
|
|
58
|
+
variableMetaMap: variableMetaMap,
|
|
59
|
+
useVariable: 'patterns',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
'en-US': [
|
|
63
|
+
{
|
|
64
|
+
templateId: 'outliers',
|
|
65
|
+
template: '${.x}',
|
|
66
|
+
separator: getDefaultSeparator('en-US'),
|
|
67
|
+
variableMetaMap: variableMetaMap,
|
|
68
|
+
useVariable: 'patterns',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
return CategoryOutlierNarrativeStrategy;
|
|
73
|
+
}(InsightNarrativeStrategy));
|
|
74
|
+
export default CategoryOutlierNarrativeStrategy;
|