import random
def add_spelling_errors(text):
noisy_text = list(text)
modified_text = []
for i in range(len(noisy_text)):
if random.random() < 0.1:
if noisy_text[i] in ['은', '는', '이', '가','을','를']:
noisy_text[i] = random.choice(['은', '는', '이', '가','를','을'])
continue
elif noisy_text[i] in ['와','과']:
noisy_text[i] = random.choice(['와','과'])
continue
elif random.random() < 0.1:
noisy_text.insert(i, random.choice(['하', '로', '니', '고', '었', '나']))
if noisy_text[i] == ' ' and random.random() < 0.1:
continue
elif random.random() < 0.1:
if i < len(noisy_text) - 1:
noisy_text[i], noisy_text[i + 1] = noisy_text[i + 1], noisy_text[i]
modified_text.append(noisy_text[i])
return ''.join(modified_text)