File size: 713 Bytes
eff2120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import json

with open('data/complexity_training_data.json', 'r', encoding='utf-8') as f:
    content = f.read()

lines = content.split('\n')
for i, line in enumerate(lines):
    if 'Convert this direct speech to indirect' in line:
        lines[i] = '    "query": "Convert this direct speech to indirect: He said he would come tomorrow.",'
        print(f'Fixed line {i+1}')
        break

content = '\n'.join(lines)
try:
    data = json.loads(content)
    print(f'JSON valid: {len(data)} records')
    with open('data/complexity_training_data.json', 'w', encoding='utf-8') as f:
        json.dump(data, f, indent=2, ensure_ascii=False)
    print('Saved!')
except Exception as e:
    print(f'Still broken: {e}')