@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,336 @@
|
|
|
1
|
+
import { max, maxIndex, mean, min, minIndex, quantile, standardDeviation, sum, variance, valueMap as statsValueMap, } from '../../statistics';
|
|
2
|
+
import { isBasicType, isBoolean, isDate, isDateString, isFloatString, isInteger, isIntegerString, isNil, isNumber, isNumberString, isString, unique, } from '../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Check if it is StringFieldInfo.
|
|
5
|
+
*/
|
|
6
|
+
export function isStringFieldInfo(x) {
|
|
7
|
+
return x.recommendation === 'string';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Check if it is NumberFieldInfo.
|
|
11
|
+
*/
|
|
12
|
+
export function isNumberFieldInfo(x) {
|
|
13
|
+
return x.recommendation === 'integer' || x.recommendation === 'float';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if it is DateFieldInfo.
|
|
17
|
+
*/
|
|
18
|
+
export function isDateFieldInfo(x) {
|
|
19
|
+
return x.recommendation === 'date';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if field is constant
|
|
23
|
+
* @param info - The {@link FieldInfo} to process
|
|
24
|
+
*/
|
|
25
|
+
export function isConst(info) {
|
|
26
|
+
return info.distinct === 1;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Checks if field is an ordinal.
|
|
30
|
+
* @param info - Field Info
|
|
31
|
+
*/
|
|
32
|
+
export function isOrdinal(info) {
|
|
33
|
+
var rawData = info.rawData, recommendation = info.recommendation;
|
|
34
|
+
if (recommendation !== 'string')
|
|
35
|
+
return false;
|
|
36
|
+
if (isConst(info))
|
|
37
|
+
return false;
|
|
38
|
+
var list = rawData.filter(function (item) { return !isNil(item) && isBasicType(item); });
|
|
39
|
+
if (list.length === 0)
|
|
40
|
+
return false;
|
|
41
|
+
var start = null;
|
|
42
|
+
var end = null;
|
|
43
|
+
var startIndex = -1;
|
|
44
|
+
var endIndex = -1;
|
|
45
|
+
var through = true;
|
|
46
|
+
while (through) {
|
|
47
|
+
var through_1 = true;
|
|
48
|
+
for (var i = 0; i < list.length; i += 1) {
|
|
49
|
+
var item = list[i];
|
|
50
|
+
var char = item[startIndex + 1];
|
|
51
|
+
if (start === null || i === 0)
|
|
52
|
+
start = char;
|
|
53
|
+
if (char !== start) {
|
|
54
|
+
through_1 = false;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!through_1)
|
|
59
|
+
break;
|
|
60
|
+
startIndex += 1;
|
|
61
|
+
}
|
|
62
|
+
through = true;
|
|
63
|
+
while (through) {
|
|
64
|
+
var through_2 = true;
|
|
65
|
+
for (var i = 0; i < list.length; i += 1) {
|
|
66
|
+
var item = list[i];
|
|
67
|
+
var char = item[item.length - 1 - (endIndex + 1)];
|
|
68
|
+
if (end === null || i === 0)
|
|
69
|
+
end = char;
|
|
70
|
+
if (char !== end) {
|
|
71
|
+
through_2 = false;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!through_2)
|
|
76
|
+
break;
|
|
77
|
+
endIndex += 1;
|
|
78
|
+
}
|
|
79
|
+
var patterns = [/\d+/, /(零|一|二|三|四|五|六|七|八|九|十)+/, /(一|二|三|四|五|六|日)/, /^[a-z]$/, /^[A-Z]$/];
|
|
80
|
+
if (startIndex === -1 && endIndex === -1)
|
|
81
|
+
return false;
|
|
82
|
+
var arr = list.map(function (item) {
|
|
83
|
+
return item.slice(startIndex === -1 ? 0 : startIndex + 1, endIndex === -1 ? undefined : item.length - endIndex - 1);
|
|
84
|
+
});
|
|
85
|
+
var _loop_1 = function (i) {
|
|
86
|
+
var p = patterns[i];
|
|
87
|
+
var notMatch = arr.some(function (item) { return !p.test(item); });
|
|
88
|
+
if (!notMatch)
|
|
89
|
+
return { value: true };
|
|
90
|
+
};
|
|
91
|
+
for (var i = 0; i < patterns.length; i += 1) {
|
|
92
|
+
var state_1 = _loop_1(i);
|
|
93
|
+
if (typeof state_1 === "object")
|
|
94
|
+
return state_1.value;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Checks if field is an unique.
|
|
100
|
+
* @param info - The {@link FieldInfo} to process
|
|
101
|
+
*/
|
|
102
|
+
export function isUnique(info) {
|
|
103
|
+
return info.distinct === info.count;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Checks if field is discrete.
|
|
107
|
+
* @remarks
|
|
108
|
+
* @param info - The {@link FieldInfo} to process
|
|
109
|
+
*/
|
|
110
|
+
export function isDiscrete(info) {
|
|
111
|
+
return info.recommendation === 'integer';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Checks if field is a continuous.
|
|
115
|
+
* @param info - The {@link FieldInfo} to process
|
|
116
|
+
*/
|
|
117
|
+
export function isContinuous(info) {
|
|
118
|
+
return info.recommendation === 'float';
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Checks if field is an interval.
|
|
122
|
+
* @param info - The {@link FieldInfo} to process
|
|
123
|
+
*/
|
|
124
|
+
export function isInterval(info) {
|
|
125
|
+
return info.recommendation === 'integer' || info.recommendation === 'float';
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Checks if field is a nominal.
|
|
129
|
+
* @param info - The {@link FieldInfo} to process
|
|
130
|
+
*/
|
|
131
|
+
export function isNominal(info) {
|
|
132
|
+
if (info.recommendation === 'boolean')
|
|
133
|
+
return true;
|
|
134
|
+
if (info.recommendation === 'string')
|
|
135
|
+
return !isOrdinal(info);
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks if field is a time.
|
|
140
|
+
* @param info - Field Info
|
|
141
|
+
*/
|
|
142
|
+
export function isTime(info) {
|
|
143
|
+
return info.recommendation === 'date';
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Analyze string field info.
|
|
147
|
+
* @param value - data
|
|
148
|
+
*/
|
|
149
|
+
export function analyzeString(value) {
|
|
150
|
+
var lenArray = value.map(function (item) { return item.length; });
|
|
151
|
+
return {
|
|
152
|
+
maxLength: max(lenArray),
|
|
153
|
+
minLength: min(lenArray),
|
|
154
|
+
meanLength: mean(lenArray),
|
|
155
|
+
containsChar: value.some(function (item) { return /[A-z]/.test(item); }),
|
|
156
|
+
containsDigit: value.some(function (item) { return /[0-9]/.test(item); }),
|
|
157
|
+
containsSpace: value.some(function (item) { return /\s/.test(item); }),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Analyze number field info.
|
|
162
|
+
* @param value - data
|
|
163
|
+
*/
|
|
164
|
+
export function analyzeNumber(value) {
|
|
165
|
+
return {
|
|
166
|
+
minimum: min(value),
|
|
167
|
+
maximum: max(value),
|
|
168
|
+
mean: mean(value),
|
|
169
|
+
percentile5: quantile(value, 5),
|
|
170
|
+
percentile25: quantile(value, 25),
|
|
171
|
+
percentile50: quantile(value, 50),
|
|
172
|
+
percentile75: quantile(value, 75),
|
|
173
|
+
percentile95: quantile(value, 95),
|
|
174
|
+
sum: sum(value),
|
|
175
|
+
variance: variance(value),
|
|
176
|
+
standardDeviation: standardDeviation(value),
|
|
177
|
+
zeros: value.filter(function (item) { return item === 0; }).length,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Analyze date field info.
|
|
182
|
+
* @param value - data
|
|
183
|
+
*/
|
|
184
|
+
export function analyzeDate(value, isInteger) {
|
|
185
|
+
if (isInteger === void 0) { isInteger = false; }
|
|
186
|
+
var list = value.map(function (item) {
|
|
187
|
+
if (isInteger) {
|
|
188
|
+
var str = "".concat(item);
|
|
189
|
+
if (str.length === 8)
|
|
190
|
+
return new Date("".concat(str.substring(0, 4), "/").concat(str.substring(4, 2), "/").concat(str.substring(6, 2))).getTime();
|
|
191
|
+
}
|
|
192
|
+
return new Date(item).getTime();
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
minimum: value[minIndex(list)],
|
|
196
|
+
maximum: value[maxIndex(list)],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Determine what type a value is, may be one of [integer float date string null].
|
|
201
|
+
*/
|
|
202
|
+
export function analyzeType(value, strictDatePattern) {
|
|
203
|
+
if (isNil(value))
|
|
204
|
+
return 'null';
|
|
205
|
+
if (isNumber(value)) {
|
|
206
|
+
if (isInteger(value))
|
|
207
|
+
return 'integer';
|
|
208
|
+
return 'float';
|
|
209
|
+
}
|
|
210
|
+
// 优先识别日期类型,避免字符型日期被判断成字符
|
|
211
|
+
if (isDate(value) || isDateString(value, strictDatePattern))
|
|
212
|
+
return 'date';
|
|
213
|
+
if (isString(value)) {
|
|
214
|
+
if (isNumberString(value)) {
|
|
215
|
+
if (value.includes('.'))
|
|
216
|
+
return 'float';
|
|
217
|
+
return 'integer';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return 'string';
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Analyze field info.
|
|
224
|
+
* @param value - data
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
export function analyzeField(value, strictDatePattern) {
|
|
228
|
+
var list = value.map(function (item) { return (isNil(item) ? null : item); });
|
|
229
|
+
var valueMap = statsValueMap(list);
|
|
230
|
+
var recommendation;
|
|
231
|
+
var nonNullArray = valueMap.null ? list.filter(function (item) { return item !== null; }) : list;
|
|
232
|
+
var typeArray = list.map(function (item) { return analyzeType(item, strictDatePattern); });
|
|
233
|
+
var types = Object.keys(statsValueMap(typeArray)).filter(function (item) { return item !== 'null'; });
|
|
234
|
+
// generate recommendation
|
|
235
|
+
switch (types.length) {
|
|
236
|
+
case 0:
|
|
237
|
+
recommendation = 'null';
|
|
238
|
+
break;
|
|
239
|
+
case 1:
|
|
240
|
+
recommendation = types[0];
|
|
241
|
+
// an integer field may be a date field
|
|
242
|
+
if (recommendation === 'integer') {
|
|
243
|
+
var data = list.filter(function (item) { return item !== null; });
|
|
244
|
+
if (data.map(function (num) { return "".concat(num); }).every(function (str) { return isDateString(str); })) {
|
|
245
|
+
recommendation = 'date';
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
break;
|
|
249
|
+
case 2:
|
|
250
|
+
if ((types.includes('integer') || types.includes('date')) && types.includes('float')) {
|
|
251
|
+
recommendation = 'float';
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
if (types.includes('integer') && types.includes('date')) {
|
|
255
|
+
// an integer field may be a date field
|
|
256
|
+
var data = list.filter(function (item) { return item !== null; });
|
|
257
|
+
if (data.map(function (num) { return "".concat(num); }).every(function (str) { return isDateString(str); })) {
|
|
258
|
+
recommendation = 'date';
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
recommendation = 'integer';
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
recommendation = 'string';
|
|
266
|
+
break;
|
|
267
|
+
default:
|
|
268
|
+
recommendation = 'string';
|
|
269
|
+
}
|
|
270
|
+
var uniqueArray = unique(nonNullArray);
|
|
271
|
+
var fieldInfo = {
|
|
272
|
+
count: value.length,
|
|
273
|
+
distinct: uniqueArray.length,
|
|
274
|
+
type: types.length <= 1 ? types[0] || 'null' : 'mixed',
|
|
275
|
+
recommendation: recommendation,
|
|
276
|
+
missing: valueMap.null || 0,
|
|
277
|
+
rawData: value,
|
|
278
|
+
valueMap: valueMap,
|
|
279
|
+
};
|
|
280
|
+
if (types.length > 1) {
|
|
281
|
+
var meta_1 = {};
|
|
282
|
+
var restNotNullArray_1 = nonNullArray;
|
|
283
|
+
types.forEach(function (item) {
|
|
284
|
+
if (item === 'date') {
|
|
285
|
+
meta_1.date = analyzeField(restNotNullArray_1.filter(function (item) { return isDateString(item); }), strictDatePattern);
|
|
286
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return !isDateString(item); });
|
|
287
|
+
}
|
|
288
|
+
else if (item === 'integer') {
|
|
289
|
+
meta_1.integer = analyzeField(restNotNullArray_1.filter(function (item) { return isIntegerString(item) && !isDateString(item); }), strictDatePattern);
|
|
290
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return !isIntegerString(item); });
|
|
291
|
+
}
|
|
292
|
+
else if (item === 'float') {
|
|
293
|
+
meta_1.float = analyzeField(restNotNullArray_1.filter(function (item) { return isFloatString(item) && !isDateString(item); }), strictDatePattern);
|
|
294
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return !isFloatString(item); });
|
|
295
|
+
}
|
|
296
|
+
else if (item === 'string') {
|
|
297
|
+
meta_1.string = analyzeField(restNotNullArray_1.filter(function (item) { return analyzeType(item, strictDatePattern) === 'string'; }));
|
|
298
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return analyzeType(item, strictDatePattern) !== 'string'; });
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
fieldInfo.meta = meta_1;
|
|
302
|
+
}
|
|
303
|
+
if (fieldInfo.distinct === 2 && fieldInfo.recommendation !== 'date') {
|
|
304
|
+
// temporarily threshold
|
|
305
|
+
if (list.length >= 100) {
|
|
306
|
+
fieldInfo.recommendation = 'boolean';
|
|
307
|
+
}
|
|
308
|
+
else if (isBoolean(uniqueArray, true)) {
|
|
309
|
+
fieldInfo.recommendation = 'boolean';
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (recommendation === 'string') {
|
|
313
|
+
Object.assign(fieldInfo, analyzeString(nonNullArray.map(function (item) { return "".concat(item); })));
|
|
314
|
+
}
|
|
315
|
+
if (recommendation === 'integer' || recommendation === 'float') {
|
|
316
|
+
Object.assign(fieldInfo, analyzeNumber(nonNullArray.map(function (item) { return item * 1; })));
|
|
317
|
+
}
|
|
318
|
+
if (recommendation === 'date') {
|
|
319
|
+
Object.assign(fieldInfo, analyzeDate(nonNullArray, fieldInfo.type === 'integer'));
|
|
320
|
+
}
|
|
321
|
+
var levelOfMeasurements = [];
|
|
322
|
+
if (isNominal(fieldInfo))
|
|
323
|
+
levelOfMeasurements.push('Nominal');
|
|
324
|
+
if (isOrdinal(fieldInfo))
|
|
325
|
+
levelOfMeasurements.push('Ordinal');
|
|
326
|
+
if (isInterval(fieldInfo))
|
|
327
|
+
levelOfMeasurements.push('Interval');
|
|
328
|
+
if (isDiscrete(fieldInfo))
|
|
329
|
+
levelOfMeasurements.push('Discrete');
|
|
330
|
+
if (isContinuous(fieldInfo))
|
|
331
|
+
levelOfMeasurements.push('Continuous');
|
|
332
|
+
if (isTime(fieldInfo))
|
|
333
|
+
levelOfMeasurements.push('Time');
|
|
334
|
+
fieldInfo.levelOfMeasurements = levelOfMeasurements;
|
|
335
|
+
return fieldInfo;
|
|
336
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
|
+
// TODO @chenluli: move @antv/algorithm from devDep to dep after this file is complete
|
|
3
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
|
+
import * as AlgorithmSync from '@antv/algorithm';
|
|
5
|
+
import { analyzeField } from '../field';
|
|
6
|
+
var GraphAlgorithms = __assign({}, AlgorithmSync);
|
|
7
|
+
function generateColDataFromArray(arr, columnNames) {
|
|
8
|
+
var fields = [];
|
|
9
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
10
|
+
var datum = arr[i];
|
|
11
|
+
for (var j = 0; j < columnNames.length; j += 1) {
|
|
12
|
+
var column = columnNames[j];
|
|
13
|
+
if (fields[j]) {
|
|
14
|
+
fields[j].push(datum[column]);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
fields[j] = [datum[column]];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return fields;
|
|
22
|
+
}
|
|
23
|
+
export function getNodeFields(nodes) {
|
|
24
|
+
var _a = __read(nodes, 1), node0 = _a[0];
|
|
25
|
+
var nodeFieldNames = node0 ? Object.keys(node0) : [];
|
|
26
|
+
var nodeFields = generateColDataFromArray(nodes, nodeFieldNames);
|
|
27
|
+
return { nodeFields: nodeFields, nodeFieldNames: nodeFieldNames };
|
|
28
|
+
}
|
|
29
|
+
export function getLinkFields(links) {
|
|
30
|
+
var _a = __read(links, 1), link0 = _a[0];
|
|
31
|
+
var linkFieldNames = link0 ? Object.keys(link0) : [];
|
|
32
|
+
var linkFields = generateColDataFromArray(links, linkFieldNames);
|
|
33
|
+
return { linkFields: linkFields, linkFieldNames: linkFieldNames };
|
|
34
|
+
}
|
|
35
|
+
// Analyze fields
|
|
36
|
+
function getFieldInfo(dataField, fieldName) {
|
|
37
|
+
var fieldInfo = analyzeField(dataField);
|
|
38
|
+
return __assign(__assign({}, fieldInfo), { name: fieldName });
|
|
39
|
+
}
|
|
40
|
+
export function getAllFieldsInfo(dataFields, fieldNames) {
|
|
41
|
+
var fields = [];
|
|
42
|
+
for (var i = 0; i < dataFields.length; i += 1) {
|
|
43
|
+
var dataField = dataFields[i];
|
|
44
|
+
fields.push(getFieldInfo(dataField, fieldNames[i]));
|
|
45
|
+
}
|
|
46
|
+
return fields;
|
|
47
|
+
}
|
|
48
|
+
/* eslint-disable no-param-reassign */
|
|
49
|
+
/**
|
|
50
|
+
* find node clusters and assign the cluster field to each node
|
|
51
|
+
* @param nodes
|
|
52
|
+
* @param links
|
|
53
|
+
*/
|
|
54
|
+
export function clusterNodes(nodes, nodeFieldsInfo, links) {
|
|
55
|
+
var MAX_CLUSTER_NUM = 10;
|
|
56
|
+
var fieldForCluster;
|
|
57
|
+
for (var i = 0; i < nodeFieldsInfo.length; i += 1) {
|
|
58
|
+
var field = nodeFieldsInfo[i];
|
|
59
|
+
if (field.levelOfMeasurements.indexOf('Nominal') > -1 ||
|
|
60
|
+
(field.levelOfMeasurements.indexOf('Ordinal') > -1 &&
|
|
61
|
+
field.missing === 0 &&
|
|
62
|
+
field.distinct > 1 &&
|
|
63
|
+
field.distinct <= MAX_CLUSTER_NUM)) {
|
|
64
|
+
fieldForCluster = field;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (fieldForCluster) {
|
|
69
|
+
for (var nodeIdx = 0; nodeIdx < nodes.length; nodeIdx += 1) {
|
|
70
|
+
nodes[nodeIdx].cluster = nodes[nodeIdx][fieldForCluster.name];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
var clusters = GraphAlgorithms.louvain({ nodes: nodes, edges: links }).clusters;
|
|
75
|
+
var values = [];
|
|
76
|
+
for (var i = 0; i < clusters.length; i += 1) {
|
|
77
|
+
var cluster = clusters[i];
|
|
78
|
+
var nodes_1 = cluster.nodes, id = cluster.id;
|
|
79
|
+
for (var nodeIdx = 0; nodeIdx < nodes_1.length; nodeIdx += 1) {
|
|
80
|
+
nodes_1[nodeIdx].cluster = id;
|
|
81
|
+
}
|
|
82
|
+
values.push(id);
|
|
83
|
+
}
|
|
84
|
+
fieldForCluster = __assign(__assign({}, analyzeField(values)), { name: 'cluster' });
|
|
85
|
+
}
|
|
86
|
+
return fieldForCluster;
|
|
87
|
+
}
|
|
88
|
+
/* eslint-disable no-param-reassign */
|
|
89
|
+
/**
|
|
90
|
+
* Calculate statistical and structural features for graph
|
|
91
|
+
* @param nodes
|
|
92
|
+
* @param links
|
|
93
|
+
*/
|
|
94
|
+
export function getAllStructFeats(nodes, links) {
|
|
95
|
+
var nodeStructFeats = [];
|
|
96
|
+
var linkStructFeats = [];
|
|
97
|
+
// TODO: whether the graph is directed need to be passed in
|
|
98
|
+
var isDirected = false;
|
|
99
|
+
var degrees = GraphAlgorithms.getDegree({ nodes: nodes, edges: links });
|
|
100
|
+
var pageRanks = GraphAlgorithms.pageRank({ nodes: nodes, edges: links });
|
|
101
|
+
var cycles = GraphAlgorithms.detectAllCycles({ nodes: nodes, edges: links }, false);
|
|
102
|
+
var directedCycles = GraphAlgorithms.detectAllDirectedCycle({ nodes: nodes, edges: links });
|
|
103
|
+
var components = GraphAlgorithms.connectedComponent({ nodes: nodes, edges: links }, false);
|
|
104
|
+
var strongConnectedComponents = GraphAlgorithms.connectedComponent({ nodes: nodes, edges: links }, true);
|
|
105
|
+
var cycleCountMap = {};
|
|
106
|
+
for (var i = 0; i < cycles.length; i += 1) {
|
|
107
|
+
var nodeIds = Object.keys(cycles[i]);
|
|
108
|
+
for (var j = 0; j < nodeIds.length; j += 1) {
|
|
109
|
+
var nodeId = nodeIds[j];
|
|
110
|
+
if (cycleCountMap[nodeId]) {
|
|
111
|
+
cycleCountMap[nodeId] += 1;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
cycleCountMap[nodeId] = 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var numberOfNodeInCycle = Object.values(cycleCountMap).filter(function (count) { return count; }).length;
|
|
119
|
+
var cycleParticipate = numberOfNodeInCycle / nodes.length;
|
|
120
|
+
for (var index = 0; index < nodes.length; index += 1) {
|
|
121
|
+
var node = nodes[index];
|
|
122
|
+
var nodeFeat = {
|
|
123
|
+
degree: degrees[node.id].degree,
|
|
124
|
+
inDegree: degrees[node.id].inDegree,
|
|
125
|
+
outDegree: degrees[node.id].outDegree,
|
|
126
|
+
pageRank: pageRanks[node.id],
|
|
127
|
+
cycleCount: cycleCountMap[node.id] || 0,
|
|
128
|
+
};
|
|
129
|
+
nodeStructFeats.push(nodeFeat);
|
|
130
|
+
nodes[index] = __assign(__assign({}, node), nodeFeat);
|
|
131
|
+
}
|
|
132
|
+
for (var index = 0; index < links.length; index += 1) {
|
|
133
|
+
var link = links[index];
|
|
134
|
+
var linkFeat = {};
|
|
135
|
+
linkStructFeats.push(linkFeat);
|
|
136
|
+
links[index] = __assign(__assign({}, link), linkFeat);
|
|
137
|
+
}
|
|
138
|
+
var nodeFeatNames = Object.keys(nodeStructFeats[0]);
|
|
139
|
+
var linkFeatNames = Object.keys(linkStructFeats[0]);
|
|
140
|
+
var nodeFeats = getAllFieldsInfo(generateColDataFromArray(nodeStructFeats, nodeFeatNames), nodeFeatNames);
|
|
141
|
+
var linkFeats = getAllFieldsInfo(generateColDataFromArray(linkStructFeats, linkFeatNames), linkFeatNames);
|
|
142
|
+
// Calculate the structural features and statistics of all nodes and links
|
|
143
|
+
var nodeDegrees = nodes.map(function (node) { return Number(node.degree); });
|
|
144
|
+
var avgDegree = nodeDegrees.reduce(function (x, y) { return x + y; }) / nodeDegrees.length;
|
|
145
|
+
var degreeDev = nodeDegrees.map(function (x) { return x - avgDegree; });
|
|
146
|
+
var degreeStd = Math.sqrt(degreeDev.map(function (x) { return Math.pow(x, 2); }).reduce(function (x, y) { return x + y; }) / (nodeDegrees.length - 1));
|
|
147
|
+
var graphInfo = {
|
|
148
|
+
isDirected: isDirected,
|
|
149
|
+
nodeCount: nodes.length,
|
|
150
|
+
linkCount: links.length,
|
|
151
|
+
isConnected: components && components.length === 1,
|
|
152
|
+
isDAG: isDirected && directedCycles.length === 0,
|
|
153
|
+
maxDegree: Math.max.apply(Math, __spreadArray([], __read(nodeDegrees), false)),
|
|
154
|
+
avgDegree: avgDegree,
|
|
155
|
+
degreeStd: degreeStd,
|
|
156
|
+
cycleParticipate: cycleParticipate,
|
|
157
|
+
cycleCount: cycles.length,
|
|
158
|
+
directedCycleCount: directedCycles.length,
|
|
159
|
+
// triangleCount: triangleMatches.length,
|
|
160
|
+
componentCount: components.length,
|
|
161
|
+
components: components,
|
|
162
|
+
strongConnectedComponents: strongConnectedComponents,
|
|
163
|
+
strongConnectedComponentCount: strongConnectedComponents.length,
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
nodeFeats: nodeFeats,
|
|
167
|
+
linkFeats: linkFeats,
|
|
168
|
+
graphInfo: graphInfo,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { analyzeField } from './field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { assert, isArray, isObject, isBasicType } from '../../utils';
|
|
2
|
+
import { generateArrayIndex, fillMissingValue, convertDataType } from './utils';
|
|
3
|
+
/* Base data structure */
|
|
4
|
+
var BaseFrame = /** @class */ (function () {
|
|
5
|
+
function BaseFrame(data, extra) {
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
|
+
this.axes = [[]];
|
|
8
|
+
this.data = [];
|
|
9
|
+
assert(!extra || isObject(extra), 'If extra exists, it must be an object.');
|
|
10
|
+
/* 1D: basic type */
|
|
11
|
+
if (isBasicType(data)) {
|
|
12
|
+
// generate indexes
|
|
13
|
+
if (extra === null || extra === void 0 ? void 0 : extra.indexes) {
|
|
14
|
+
this.setAxis(0, extra === null || extra === void 0 ? void 0 : extra.indexes);
|
|
15
|
+
this.data = Array(extra === null || extra === void 0 ? void 0 : extra.indexes.length).fill(convertDataType(fillMissingValue(data, extra === null || extra === void 0 ? void 0 : extra.fillValue), (_a = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _a === void 0 ? void 0 : _a[0]));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.data = [convertDataType(fillMissingValue(data, extra === null || extra === void 0 ? void 0 : extra.fillValue), (_b = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _b === void 0 ? void 0 : _b[0])];
|
|
19
|
+
this.setAxis(0, [0]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (isArray(data)) {
|
|
23
|
+
/* 1D: array */
|
|
24
|
+
var legal = true;
|
|
25
|
+
for (var i = 0; i < data.length; i += 1) {
|
|
26
|
+
var datum = data[i];
|
|
27
|
+
// For DataFrame, as long as any datum in data is basic type, it's a 1D array
|
|
28
|
+
if (!isBasicType(datum)) {
|
|
29
|
+
legal = false;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this.setAxis(0, generateArrayIndex(data, extra === null || extra === void 0 ? void 0 : extra.indexes));
|
|
34
|
+
if (legal) {
|
|
35
|
+
if (extra === null || extra === void 0 ? void 0 : extra.indexes) {
|
|
36
|
+
assert(((_c = extra === null || extra === void 0 ? void 0 : extra.indexes) === null || _c === void 0 ? void 0 : _c.length) === data.length, "Index length is ".concat(extra === null || extra === void 0 ? void 0 : extra.indexes.length, ", but data size ").concat(data.length));
|
|
37
|
+
this.setAxis(0, extra === null || extra === void 0 ? void 0 : extra.indexes);
|
|
38
|
+
}
|
|
39
|
+
this.data = (extra === null || extra === void 0 ? void 0 : extra.fillValue) ? data.map(function (datum) { return fillMissingValue(datum, extra === null || extra === void 0 ? void 0 : extra.fillValue); }) : data;
|
|
40
|
+
if ((_d = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
41
|
+
for (var i = 0; i < this.data.length; i += 1) {
|
|
42
|
+
this.data[i] = convertDataType(this.data[i], (_e = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _e === void 0 ? void 0 : _e[0]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
Object.defineProperty(BaseFrame.prototype, "indexes", {
|
|
49
|
+
get: function () {
|
|
50
|
+
return this.getAxis(0);
|
|
51
|
+
},
|
|
52
|
+
enumerable: false,
|
|
53
|
+
configurable: true
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(BaseFrame.prototype, "columns", {
|
|
56
|
+
get: function () {
|
|
57
|
+
return this.getAxis(1);
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
BaseFrame.prototype.getAxis = function (axis) {
|
|
63
|
+
return this.axes[axis];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Set axis. Only the 0 and 1 are currently supported.
|
|
67
|
+
* @param axis
|
|
68
|
+
* @param labels
|
|
69
|
+
*/
|
|
70
|
+
BaseFrame.prototype.setAxis = function (axis, values) {
|
|
71
|
+
assert(isArray(values), 'Index or columns must be Axis array.');
|
|
72
|
+
this.axes[axis] = values;
|
|
73
|
+
};
|
|
74
|
+
return BaseFrame;
|
|
75
|
+
}());
|
|
76
|
+
export default BaseFrame;
|