Spaces:
Running
Running
| 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}') | |