nahj/temp2.py
2025-08-21 19:04:16 +03:30

24 lines
560 B
Python

import json
path = './output/nahj_speechs_new.json'
with open(path, 'r' , encoding='utf-8') as f:
records = json.load(f)
for index, item in enumerate(records):
try:
if item['sentences']:
continue
except:
sentences = []
sentences.append(item['persian_translate'].strip())
item['sentences'] = sentences
path = './output/nahj_speechs_complete.json'
data = json.dumps(records, ensure_ascii=False, indent=2)
with open(path, 'w' , encoding='utf-8') as f:
f.write(data)
print('finished!')