lines = [] en_lines = [] cn_lines = [] with open('translation2019zh_train.json' , 'r', encoding='UTF-8') as r: lines = r.readlines()
for line in lines[0: 10000]: jf = json.loads(line) en_lines.append(jf['english'] + '\n') cn_lines.append(jf['chinese'] + '\n')
with open('src-train.txt' , 'w', encoding='UTF-8') as w: w.writelines(en_lines) with open('tgt-train.txt' , 'w', encoding='UTF-8') as w: w.writelines(cn_lines)