-
Notifications
You must be signed in to change notification settings - Fork 0
/
qrecc_filter.py
36 lines (28 loc) · 997 Bytes
/
qrecc_filter.py
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
# from builtins import breakpoint, print
# from builtins import input
from tracemalloc import start
from urllib import response
import tqdm
import json
import nltk
import copy
import sys
input_path = 'QRECC/query_refomulation.json'
output_path = 'QRECC/query_refomulation_filter.json'
with open(input_path, 'r') as f:
data_source = json.load(f)
# new_records = []
k = 0
# print(len(data_source))
cand_topics = list(set([item['topic_number'] for item in data_source if item['input'][0] == item['target']]))
new_records = [item for item in data_source if item['topic_number'] in cand_topics]
bad_records = [item for item in data_source if item['topic_number'] not in cand_topics]
print(bad_records[:5])
# print(len(new_records))
# with open(output_path, 'w') as f:
# json.dump(new_records, f, ensure_ascii=False, indent=2)
# for item in data_source:
# input_sents = item['input']
# if input_sents[0] != item['target']:
# print(input_sents)
# breakpoint()