File size: 1,843 Bytes
bf66e8b
 
 
b6149ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---

license: apache-2.0
---


# construct_text_correction

使用程序自动构造文本纠错数据集,包含拼写和语法纠错数据,可用于中文校对模型的训练。

## Data Fields

| Field  | Type   | Description                   |
| ------ | ------ | ----------------------------- |
| source | string | 可能包含拼写/语法错误的源句子               |
| target | string | 纠错后的目标句子                      |
| label  | int    | 源句子中是否包含错误,若为1,则包含错误,否则不包含错误。 |

```json

{

    "source": "健全国有林区经营管理体制,完散集体林权制度改革。",

    "target": "健全国有林区经营管理体制,完善集体林权制度改革。",

    "label": 1

}

```

## Construction

安装 [ltp](https://github.com/HIT-SCIR/ltp):

```shell

pip install ltp ltp-core ltp-extension

```

生成 4k 条纠错句子对 `4k.jsonl````shell

python finetune_data.py \

    --input sentences/4k.txt \

    --output 4k.jsonl \

    --ltp_model LTP/legacy \

    --basic_hanzi confusion/basic_hanzi_2500.txt \

    --shape_confusion confusion/shape_confusion.txt \

    --sound_confusion confusion/pinyin.txt \

    --same_ratio 0.1 \

    --repeat_ratio 0.15 \

    --delete_ratio 0.15 \

    --sound_ratio 0.5 \

    --shape_ratio 0.1

```

生成 20k 条纠错句子对 `20k.jsonl````shell

python finetune_data.py \

    --input sentences/20k.txt \

    --output 20k.jsonl \

    --ltp_model LTP/legacy \

    --basic_hanzi confusion/basic_hanzi_2500.txt \

    --shape_confusion confusion/shape_confusion.txt \

    --sound_confusion confusion/pinyin_expand.txt \

    --same_ratio 0.1 \

    --repeat_ratio 0.15 \

    --delete_ratio 0.15 \

    --sound_ratio 0.5 \

    --shape_ratio 0.1

```