@h-ai/datapipe 0.1.0-alpha.65 → 0.1.0-alpha.67
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.en.md +16 -7
- package/README.ja.md +16 -7
- package/README.md +17 -8
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[Framework home](../../README.en.md) · Related modules: [@h-ai/core](../core/README.en.md)
|
|
6
6
|
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
7
9
|
A data processing pipeline module for text cleaning (`clean`), chunking (`chunk`), and composable pipelines (`pipeline`). Pure functions; no initialization required.
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Core features
|
|
10
12
|
|
|
11
13
|
| Feature | Description |
|
|
12
14
|
| -------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
@@ -16,13 +18,20 @@ A data processing pipeline module for text cleaning (`clean`), chunking (`chunk`
|
|
|
16
18
|
|
|
17
19
|
> Security: `customReplacements` and `separator` in `mode: 'custom'` are used as regular expressions. Only provide trusted, reviewed patterns; do not interpolate user input directly into regexes, to avoid ReDoS or unintended broad replacements.
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## Getting started
|
|
22
|
+
|
|
23
|
+
### Quick start
|
|
20
24
|
|
|
21
25
|
```ts
|
|
22
26
|
import { datapipe, HaiDatapipeError } from '@h-ai/datapipe'
|
|
23
27
|
|
|
28
|
+
const rawText = '<p>Hello framework.</p>'
|
|
29
|
+
const text = '# Getting started\n\nHello framework.'
|
|
30
|
+
|
|
24
31
|
// 直接清洗
|
|
25
|
-
const cleaned = datapipe.clean(
|
|
32
|
+
const cleaned = datapipe.clean(rawText, { removeHtml: true })
|
|
33
|
+
if (!cleaned.success)
|
|
34
|
+
throw new Error(cleaned.error.message)
|
|
26
35
|
|
|
27
36
|
// 按 Markdown 标题分块
|
|
28
37
|
const chunks = datapipe.chunk(text, { mode: 'markdown', maxSize: 2000 })
|
|
@@ -36,7 +45,7 @@ const result = await datapipe.pipeline()
|
|
|
36
45
|
.run(rawText)
|
|
37
46
|
```
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
### Chunking modes
|
|
40
49
|
|
|
41
50
|
| Mode | Description |
|
|
42
51
|
| --------- | ------------------------------------- |
|
|
@@ -48,7 +57,7 @@ const result = await datapipe.pipeline()
|
|
|
48
57
|
| character | Split by character count |
|
|
49
58
|
| custom | Custom separator (requires separator) |
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
### Error handling
|
|
52
61
|
|
|
53
62
|
All operations return `HaiResult<T>`; check `result.success` for success or failure. Error codes use the string format `hai:datapipe:NNN`.
|
|
54
63
|
|
|
@@ -62,14 +71,14 @@ if (!result.success) {
|
|
|
62
71
|
case HaiDatapipeError.CONFIG_ERROR.code:
|
|
63
72
|
// 配置参数校验失败
|
|
64
73
|
break
|
|
65
|
-
case HaiDatapipeError.
|
|
74
|
+
case HaiDatapipeError.CHUNK_FAILED.code:
|
|
66
75
|
// 输入或自定义正则导致处理失败;记录错误并回退到安全默认策略
|
|
67
76
|
break
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
```
|
|
71
80
|
|
|
72
|
-
##
|
|
81
|
+
## Development and testing
|
|
73
82
|
|
|
74
83
|
```bash
|
|
75
84
|
pnpm --filter @h-ai/datapipe test
|
package/README.ja.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
[フレームワークのホーム](../../README.ja.md) · 関連モジュール:[@h-ai/core](../core/README.ja.md)
|
|
6
6
|
|
|
7
|
+
## 概要
|
|
8
|
+
|
|
7
9
|
テキストのクリーニング(clean)、分割(chunk)、パイプラインの合成(pipeline)を提供するデータ処理モジュールです。純粋関数で構成され、初期化は不要です。
|
|
8
10
|
|
|
9
11
|
## 主な機能
|
|
@@ -16,13 +18,20 @@
|
|
|
16
18
|
|
|
17
19
|
> セキュリティ:`customReplacements` と `mode: 'custom'` の `separator` は正規表現として使用されます。信頼できる検証済みのパターンのみを渡し、ReDoS や意図しない広範囲の置換を防ぐため、ユーザー入力を直接正規表現に組み込まないでください。
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## 使い始める
|
|
22
|
+
|
|
23
|
+
### クイックスタート
|
|
20
24
|
|
|
21
25
|
```ts
|
|
22
26
|
import { datapipe, HaiDatapipeError } from '@h-ai/datapipe'
|
|
23
27
|
|
|
28
|
+
const rawText = '<p>Hello framework.</p>'
|
|
29
|
+
const text = '# Getting started\n\nHello framework.'
|
|
30
|
+
|
|
24
31
|
// 直接清洗
|
|
25
|
-
const cleaned = datapipe.clean(
|
|
32
|
+
const cleaned = datapipe.clean(rawText, { removeHtml: true })
|
|
33
|
+
if (!cleaned.success)
|
|
34
|
+
throw new Error(cleaned.error.message)
|
|
26
35
|
|
|
27
36
|
// 按 Markdown 标题分块
|
|
28
37
|
const chunks = datapipe.chunk(text, { mode: 'markdown', maxSize: 2000 })
|
|
@@ -36,7 +45,7 @@ const result = await datapipe.pipeline()
|
|
|
36
45
|
.run(rawText)
|
|
37
46
|
```
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
### 分割モード
|
|
40
49
|
|
|
41
50
|
| モード | 説明 |
|
|
42
51
|
| --------- | ------------------------------------ |
|
|
@@ -48,7 +57,7 @@ const result = await datapipe.pipeline()
|
|
|
48
57
|
| character | 文字数で分割 |
|
|
49
58
|
| custom | 独自の区切り文字(separator が必要) |
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
### エラー処理
|
|
52
61
|
|
|
53
62
|
すべての操作は `HaiResult<T>` を返します。`result.success` で成功・失敗を判定します。エラーコードは文字列形式 `hai:datapipe:NNN` です。
|
|
54
63
|
|
|
@@ -62,19 +71,19 @@ if (!result.success) {
|
|
|
62
71
|
case HaiDatapipeError.CONFIG_ERROR.code:
|
|
63
72
|
// 配置参数校验失败
|
|
64
73
|
break
|
|
65
|
-
case HaiDatapipeError.
|
|
74
|
+
case HaiDatapipeError.CHUNK_FAILED.code:
|
|
66
75
|
// 输入或自定义正则导致处理失败;记录错误并回退到安全默认策略
|
|
67
76
|
break
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
```
|
|
71
80
|
|
|
72
|
-
##
|
|
81
|
+
## 開発とテスト
|
|
73
82
|
|
|
74
83
|
```bash
|
|
75
84
|
pnpm --filter @h-ai/datapipe test
|
|
76
85
|
```
|
|
77
86
|
|
|
78
|
-
##
|
|
87
|
+
## ライセンス
|
|
79
88
|
|
|
80
89
|
Apache-2.0
|
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[框架首页](../../README.md) · 相关模块:[@h-ai/core](../core/README.md)
|
|
6
6
|
|
|
7
|
+
## 简介
|
|
8
|
+
|
|
7
9
|
数据处理管线模块,提供文本清洗(clean)、分块(chunk)和可组合管线(pipeline)功能。纯函数模块,无需初始化。
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## 核心功能清单
|
|
10
12
|
|
|
11
13
|
| 功能 | 说明 |
|
|
12
14
|
| -------- | ----------------------------------------------------------- |
|
|
@@ -16,13 +18,20 @@
|
|
|
16
18
|
|
|
17
19
|
> 安全提示:`customReplacements` 与 `mode: 'custom'` 的 `separator` 会作为正则使用。仅传入受信任、已审查的模式;不要把用户输入直接拼进正则,避免 ReDoS 或意外大范围替换。
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## 使用入门
|
|
22
|
+
|
|
23
|
+
### 快速开始
|
|
20
24
|
|
|
21
25
|
```ts
|
|
22
26
|
import { datapipe, HaiDatapipeError } from '@h-ai/datapipe'
|
|
23
27
|
|
|
28
|
+
const rawText = '<p>Hello framework.</p>'
|
|
29
|
+
const text = '# Getting started\n\nHello framework.'
|
|
30
|
+
|
|
24
31
|
// 直接清洗
|
|
25
|
-
const cleaned = datapipe.clean(
|
|
32
|
+
const cleaned = datapipe.clean(rawText, { removeHtml: true })
|
|
33
|
+
if (!cleaned.success)
|
|
34
|
+
throw new Error(cleaned.error.message)
|
|
26
35
|
|
|
27
36
|
// 按 Markdown 标题分块
|
|
28
37
|
const chunks = datapipe.chunk(text, { mode: 'markdown', maxSize: 2000 })
|
|
@@ -36,7 +45,7 @@ const result = await datapipe.pipeline()
|
|
|
36
45
|
.run(rawText)
|
|
37
46
|
```
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
### 分块模式
|
|
40
49
|
|
|
41
50
|
| 模式 | 说明 |
|
|
42
51
|
| --------- | -------------------------------- |
|
|
@@ -48,7 +57,7 @@ const result = await datapipe.pipeline()
|
|
|
48
57
|
| character | 按字符数分块 |
|
|
49
58
|
| custom | 自定义分隔符(需提供 separator) |
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
### 错误处理
|
|
52
61
|
|
|
53
62
|
所有操作返回 `HaiResult<T>`,通过 `result.success` 判断成功或失败。错误码为字符串格式 `hai:datapipe:NNN`。
|
|
54
63
|
|
|
@@ -62,19 +71,19 @@ if (!result.success) {
|
|
|
62
71
|
case HaiDatapipeError.CONFIG_ERROR.code:
|
|
63
72
|
// 配置参数校验失败
|
|
64
73
|
break
|
|
65
|
-
case HaiDatapipeError.
|
|
74
|
+
case HaiDatapipeError.CHUNK_FAILED.code:
|
|
66
75
|
// 输入或自定义正则导致处理失败;记录错误并回退到安全默认策略
|
|
67
76
|
break
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
```
|
|
71
80
|
|
|
72
|
-
##
|
|
81
|
+
## 开发测试
|
|
73
82
|
|
|
74
83
|
```bash
|
|
75
84
|
pnpm --filter @h-ai/datapipe test
|
|
76
85
|
```
|
|
77
86
|
|
|
78
|
-
##
|
|
87
|
+
## 许可证
|
|
79
88
|
|
|
80
89
|
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/datapipe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.67",
|
|
5
5
|
"description": "Data processing pipeline module for hai-framework: clean, chunk, transform",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@h-ai/core": "0.1.0-alpha.
|
|
24
|
+
"@h-ai/core": "0.1.0-alpha.67",
|
|
25
25
|
"zod": "^4.6.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|