File size: 1,311 Bytes
58e7874
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os

import json
from tqdm import tqdm
import os
import ast


def read_json(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        data = json.load(file)
    return data


def write_json(file_path, data):
    with open(file_path, 'w', encoding='utf-8') as file:
        json.dump(data, file, ensure_ascii=False, indent=4)


def read_jsonl(file_path):
    data = []
    with open(file_path, 'r', encoding='utf-8') as f:
        for line in f:
            json_obj = json.loads(line.strip())  # 每行解析为一个字典
            data.append(json_obj)
    return data


def write_jsonl(file_path, data):
    with open(file_path, 'w', encoding='utf-8') as f:
        for item in data:
            json.dump(item, f, ensure_ascii=False)  # 将每个字典写入文件
            f.write('\n')  # 每个 JSON 对象占一行


data = read_json('/Users/baixuehai/Downloads/Benchmark/singleturn/singleturn.json')

remove_data = []
for x in data:
    type = data[x]["edit_type"]
    if type == "remove":
        sub_path = data[x]["id"]
        img_path = os.path.join('/Users/baixuehai/Downloads/Benchmark/singleturn', sub_path)
        if os.path.exists(img_path):
            remove_data.append(data[x])

write_jsonl('/Users/baixuehai/Downloads/Benchmark/remove.jsonl', remove_data)