Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
| 4 |
+
|
| 5 |
+
# construct_text_correction
|
| 6 |
+
|
| 7 |
+
使用程序自动构造文本纠错数据集,包含拼写和语法纠错数据,可用于中文校对模型的训练。
|
| 8 |
+
|
| 9 |
+
## Data Fields
|
| 10 |
+
|
| 11 |
+
| Field | Type | Description |
|
| 12 |
+
| ------ | ------ | ----------------------------- |
|
| 13 |
+
| source | string | 可能包含拼写/语法错误的源句子 |
|
| 14 |
+
| target | string | 纠错后的目标句子 |
|
| 15 |
+
| label | int | 源句子中是否包含错误,若为1,则包含错误,否则不包含错误。 |
|
| 16 |
+
|
| 17 |
+
```json
|
| 18 |
+
{
|
| 19 |
+
"source": "健全国有林区经营管理体制,完散集体林权制度改革。",
|
| 20 |
+
"target": "健全国有林区经营管理体制,完善集体林权制度改革。",
|
| 21 |
+
"label": 1
|
| 22 |
+
}
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
## Construction
|
| 26 |
+
|
| 27 |
+
安装 [ltp](https://github.com/HIT-SCIR/ltp):
|
| 28 |
+
|
| 29 |
+
```shell
|
| 30 |
+
pip install ltp ltp-core ltp-extension
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
生成 4k 条纠错句子对 `4k.jsonl`:
|
| 34 |
+
|
| 35 |
+
```shell
|
| 36 |
+
python finetune_data.py \
|
| 37 |
+
--input sentences/4k.txt \
|
| 38 |
+
--output 4k.jsonl \
|
| 39 |
+
--ltp_model LTP/legacy \
|
| 40 |
+
--basic_hanzi confusion/basic_hanzi_2500.txt \
|
| 41 |
+
--shape_confusion confusion/shape_confusion.txt \
|
| 42 |
+
--sound_confusion confusion/pinyin.txt \
|
| 43 |
+
--same_ratio 0.1 \
|
| 44 |
+
--repeat_ratio 0.15 \
|
| 45 |
+
--delete_ratio 0.15 \
|
| 46 |
+
--sound_ratio 0.5 \
|
| 47 |
+
--shape_ratio 0.1
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
生成 20k 条纠错句子对 `20k.jsonl`:
|
| 51 |
+
|
| 52 |
+
```shell
|
| 53 |
+
python finetune_data.py \
|
| 54 |
+
--input sentences/20k.txt \
|
| 55 |
+
--output 20k.jsonl \
|
| 56 |
+
--ltp_model LTP/legacy \
|
| 57 |
+
--basic_hanzi confusion/basic_hanzi_2500.txt \
|
| 58 |
+
--shape_confusion confusion/shape_confusion.txt \
|
| 59 |
+
--sound_confusion confusion/pinyin_expand.txt \
|
| 60 |
+
--same_ratio 0.1 \
|
| 61 |
+
--repeat_ratio 0.15 \
|
| 62 |
+
--delete_ratio 0.15 \
|
| 63 |
+
--sound_ratio 0.5 \
|
| 64 |
+
--shape_ratio 0.1
|
| 65 |
+
```
|