mirror of
https://github.com/lilakk/BLEUBERI.git
synced 2026-04-19 12:58:12 +00:00
23 lines
664 B
Python
23 lines
664 B
Python
"""
|
|
Merge two conversation files into one
|
|
|
|
Usage: python3 -m fastchat.data.merge --in file1.json file2.json --out merged.json
|
|
"""
|
|
|
|
import argparse
|
|
import json
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--in-file", type=str, required=True, nargs="+")
|
|
parser.add_argument("--out-file", type=str, default="merged.json")
|
|
args = parser.parse_args()
|
|
|
|
new_content = []
|
|
for in_file in args.in_file:
|
|
content = json.load(open(in_file, "r"))
|
|
new_content.extend(content)
|
|
|
|
print(f"#out: {len(new_content)}")
|
|
json.dump(new_content, open(args.out_file, "w"), indent=2, ensure_ascii=False)
|