MCPcopy Create free account
hub / github.com/ZinYY/TreeLoRA / transform_json

Function transform_json

assist_scripts/format_json.py:34–50  ·  view source on GitHub ↗
(input_path, output_path)

Source from the content-addressed store, hash-verified

32
33
34def transform_json(input_path, output_path):
35 # Read the input JSON file
36 with open(input_path, 'r', encoding='utf-8') as f:
37 data = json.load(f)
38
39 # Transform the data
40 transformed_data = []
41 for item in data:
42 transformed_item = {
43 'prompt': item['sentence'],
44 'answer': item['label']
45 }
46 transformed_data.append(transformed_item)
47
48 # Write the transformed data to output file
49 with open(output_path, 'w', encoding='utf-8') as f:
50 json.dump(transformed_data, f, ensure_ascii=False, indent=2)
51
52
53def process_directory(directory_path):

Callers 1

process_directoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected