Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
| 1 |
---
|
| 2 |
pipeline_tag: summarization
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
pipeline_tag: summarization
|
| 3 |
+
|
| 4 |
+
---
|
| 5 |
+
import random
|
| 6 |
+
|
| 7 |
+
def add_spelling_errors(text):
|
| 8 |
+
noisy_text = list(text)
|
| 9 |
+
modified_text = []
|
| 10 |
+
for i in range(len(noisy_text)):
|
| 11 |
+
if random.random() < 0.1:
|
| 12 |
+
if noisy_text[i] in ['은', '는', '이', '가','을','를']:
|
| 13 |
+
noisy_text[i] = random.choice(['은', '는', '이', '가','를','을']) # 语法
|
| 14 |
+
continue
|
| 15 |
+
elif noisy_text[i] in ['와','과']:
|
| 16 |
+
noisy_text[i] = random.choice(['와','과']) # 语法
|
| 17 |
+
continue
|
| 18 |
+
elif random.random() < 0.1:
|
| 19 |
+
# 随机插入字符
|
| 20 |
+
noisy_text.insert(i, random.choice(['하', '로', '니', '고', '었', '나']))
|
| 21 |
+
# 这里不需要增加i,因为insert操作会将插入位置之后的字符向后移动
|
| 22 |
+
#i += 1 # 移动到下一个位置,因为插入了一个字符
|
| 23 |
+
|
| 24 |
+
# 删除空格或交换字符
|
| 25 |
+
if noisy_text[i] == ' ' and random.random() < 0.1:
|
| 26 |
+
continue # 跳过空格
|
| 27 |
+
|
| 28 |
+
elif random.random() < 0.1: # 控制交换字符的概率
|
| 29 |
+
if i < len(noisy_text) - 1:
|
| 30 |
+
noisy_text[i], noisy_text[i + 1] = noisy_text[i + 1], noisy_text[i]
|
| 31 |
+
|
| 32 |
+
modified_text.append(noisy_text[i])
|
| 33 |
+
|
| 34 |
+
return ''.join(modified_text)
|