@liuhange/dsh-data-quality-scoring 2.0.0
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 +34 -0
- package/lib/types/accuracyScorer.d.ts +5 -0
- package/lib/types/completenessScorer.d.ts +6 -0
- package/lib/types/consistencyScorer.d.ts +6 -0
- package/lib/types/defaultScoringRules.d.ts +3 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/invariant.d.ts +3 -0
- package/lib/types/issueCollector.d.ts +5 -0
- package/lib/types/qualityReportGenerator.d.ts +6 -0
- package/lib/types/suggestionGenerator.d.ts +6 -0
- package/lib/types/timelinessScorer.d.ts +5 -0
- package/lib/types/types.d.ts +54 -0
- package/lib/types/weightedScoreCalculator.d.ts +10 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @liuhange/dsh-data-quality-scoring
|
|
2
|
+
|
|
3
|
+
数据质量评分插件:对数据完整性、准确性、一致性、时效性多维度评分,生成质量报告和改进建议。
|
|
4
|
+
|
|
5
|
+
## Tool 接口
|
|
6
|
+
|
|
7
|
+
### `score_data_quality`
|
|
8
|
+
|
|
9
|
+
对数据文件进行多维度质量评分,生成 JSON + Markdown 双格式报告。
|
|
10
|
+
|
|
11
|
+
**参数:**
|
|
12
|
+
- `filePath` (string, 必填): 待评分数据文件路径
|
|
13
|
+
- `outputPathDir` (string, 可选): 报告输出目录,默认数据文件所在目录
|
|
14
|
+
|
|
15
|
+
**输出:**
|
|
16
|
+
- `quality_report.json`: 质量评分 JSON 报告
|
|
17
|
+
- `quality_report.md`: 质量评分 Markdown 报告(首行 `【数据质量评分报告】`)
|
|
18
|
+
|
|
19
|
+
## 评分维度
|
|
20
|
+
|
|
21
|
+
| 维度 | 说明 | 计算方式 |
|
|
22
|
+
|------|------|---------|
|
|
23
|
+
| 完整性 | 缺失值比例 | (非缺失值总数 / 字段值总数) × 100 |
|
|
24
|
+
| 准确性 | 格式合规率 + 值域合规率 | 加权平均 × 100 |
|
|
25
|
+
| 一致性 | 跨字段约束满足率 | (满足约束记录数 / 受约束记录数) × 100 |
|
|
26
|
+
| 时效性 | 数据新鲜度 | (1 - 过期比例) × 100 |
|
|
27
|
+
|
|
28
|
+
## 配置节点
|
|
29
|
+
|
|
30
|
+
`business-rules.json` → `qualityScoring` 节点。缺失时使用默认配置(权重各 0.25,阈值 60)。
|
|
31
|
+
|
|
32
|
+
## v1.0 兼容性
|
|
33
|
+
|
|
34
|
+
本插件为 v2.0 新增,不影响 v1.0 功能。配置缺失时降级到默认评分规则。
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { QualityScoringResult } from './types.js';
|
|
2
|
+
export declare class QualityReportGenerator {
|
|
3
|
+
writeJson(filePath: string, result: QualityScoringResult): Promise<void>;
|
|
4
|
+
writeMarkdown(filePath: string, result: QualityScoringResult): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=qualityReportGenerator.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { QualityDimensions } from './types.js';
|
|
2
|
+
import type { QualityScoringConfig } from '@liuhange/dsh-data-asset-shared';
|
|
3
|
+
export declare class SuggestionGenerator {
|
|
4
|
+
generate(dimensions: QualityDimensions, thresholds: QualityScoringConfig['thresholds']): string[];
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=suggestionGenerator.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type QualityDimension = 'completeness' | 'accuracy' | 'consistency' | 'timeliness';
|
|
2
|
+
export type IssueSeverity = 'low' | 'medium' | 'high';
|
|
3
|
+
export interface ScoreDataQualityParams {
|
|
4
|
+
filePath: string;
|
|
5
|
+
outputPathDir?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface QualityIssue {
|
|
8
|
+
dimension: QualityDimension;
|
|
9
|
+
description: string;
|
|
10
|
+
location: string;
|
|
11
|
+
severity: IssueSeverity;
|
|
12
|
+
}
|
|
13
|
+
export interface DimensionScore {
|
|
14
|
+
score: number;
|
|
15
|
+
weight: number;
|
|
16
|
+
weightNormalized: number;
|
|
17
|
+
subScores?: Record<string, number>;
|
|
18
|
+
issues: QualityIssue[];
|
|
19
|
+
suggestion?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface QualityDimensions {
|
|
22
|
+
completeness: DimensionScore;
|
|
23
|
+
accuracy: DimensionScore;
|
|
24
|
+
consistency: DimensionScore;
|
|
25
|
+
timeliness: DimensionScore;
|
|
26
|
+
}
|
|
27
|
+
export interface QualityScoringResult {
|
|
28
|
+
totalScore: number;
|
|
29
|
+
dimensions: QualityDimensions;
|
|
30
|
+
issues: QualityIssue[];
|
|
31
|
+
suggestions: string[];
|
|
32
|
+
weightsNormalized: boolean;
|
|
33
|
+
scoredAt: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ScoreDataQualityResult {
|
|
36
|
+
jsonReportPath: string;
|
|
37
|
+
markdownReportPath: string;
|
|
38
|
+
report: QualityScoringResult;
|
|
39
|
+
totalScore: number;
|
|
40
|
+
dimensions: QualityDimensions;
|
|
41
|
+
status: 'SUCCESS' | 'FAILED';
|
|
42
|
+
configStatus: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ScoringContext {
|
|
45
|
+
records: Record<string, unknown>[];
|
|
46
|
+
fieldNames: string[];
|
|
47
|
+
config: unknown;
|
|
48
|
+
}
|
|
49
|
+
export interface DimensionScoringResult {
|
|
50
|
+
score: number;
|
|
51
|
+
issues: QualityIssue[];
|
|
52
|
+
subScores?: Record<string, number>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { QualityDimensions } from './types.js';
|
|
2
|
+
import type { QualityScoringConfig } from '@liuhange/dsh-data-asset-shared';
|
|
3
|
+
export declare class WeightedScoreCalculator {
|
|
4
|
+
calculate(dimensions: QualityDimensions, weights: QualityScoringConfig['weights']): {
|
|
5
|
+
totalScore: number;
|
|
6
|
+
weightsNormalized: boolean;
|
|
7
|
+
normalizedWeights: QualityScoringConfig['weights'];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=weightedScoreCalculator.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@liuhange/dsh-data-quality-scoring",
|
|
3
|
+
"description": "Data quality scoring plugin: multi-dimensional scoring (completeness/accuracy/consistency/timeliness) with weighted total and improvement suggestions",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/liuhange789/data-asset-inspector.git",
|
|
11
|
+
"directory": "packages/data-asset/data-quality-scoring"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/invariant.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@deepseek-ai/cordis": "^0.1.0",
|
|
36
|
+
"@deepseek-ai/dsh-tools": "^0.1.0",
|
|
37
|
+
"@liuhange/dsh-data-asset-shared": "^2.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|