Update process.py
Browse files- process.py +14 -3
process.py
CHANGED
@@ -62,20 +62,30 @@ if __name__ == '__main__':
|
|
62 |
}) + '\n')
|
63 |
|
64 |
with open(f'dataset/train.jsonl', 'w') as f:
|
65 |
-
for relation, df_p in
|
66 |
if len(df_p) < 2:
|
67 |
continue
|
68 |
if relation in exclude:
|
69 |
continue
|
70 |
print(relation)
|
71 |
-
df_n = dev1_n[dev1_n['relation'] == relation]
|
72 |
f.write(json.dumps({
|
73 |
'relation_type': relation,
|
74 |
'positives': df_p[['head', 'tail']].to_numpy().tolist(),
|
75 |
-
'negatives':
|
76 |
}) + '\n')
|
77 |
|
78 |
with open(f'dataset/valid.jsonl', 'w') as f:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
for relation, df_p in dev2_p.groupby('relation'):
|
80 |
if len(df_p) < 2:
|
81 |
continue
|
@@ -87,3 +97,4 @@ if __name__ == '__main__':
|
|
87 |
'positives': df_p[['head', 'tail']].to_numpy().tolist(),
|
88 |
'negatives': df_n[['head', 'tail']].to_numpy().tolist()
|
89 |
}) + '\n')
|
|
|
|
62 |
}) + '\n')
|
63 |
|
64 |
with open(f'dataset/train.jsonl', 'w') as f:
|
65 |
+
for relation, df_p in train_p.groupby('relation'):
|
66 |
if len(df_p) < 2:
|
67 |
continue
|
68 |
if relation in exclude:
|
69 |
continue
|
70 |
print(relation)
|
|
|
71 |
f.write(json.dumps({
|
72 |
'relation_type': relation,
|
73 |
'positives': df_p[['head', 'tail']].to_numpy().tolist(),
|
74 |
+
'negatives': []
|
75 |
}) + '\n')
|
76 |
|
77 |
with open(f'dataset/valid.jsonl', 'w') as f:
|
78 |
+
for relation, df_p in dev1_p.groupby('relation'):
|
79 |
+
if len(df_p) < 2:
|
80 |
+
continue
|
81 |
+
if relation in exclude:
|
82 |
+
continue
|
83 |
+
df_n = dev1_n[dev1_n['relation'] == relation]
|
84 |
+
f.write(json.dumps({
|
85 |
+
'relation_type': relation,
|
86 |
+
'positives': df_p[['head', 'tail']].to_numpy().tolist(),
|
87 |
+
'negatives': df_n[['head', 'tail']].to_numpy().tolist()
|
88 |
+
}) + '\n')
|
89 |
for relation, df_p in dev2_p.groupby('relation'):
|
90 |
if len(df_p) < 2:
|
91 |
continue
|
|
|
97 |
'positives': df_p[['head', 'tail']].to_numpy().tolist(),
|
98 |
'negatives': df_n[['head', 'tail']].to_numpy().tolist()
|
99 |
}) + '\n')
|
100 |
+
|