-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfff66b
commit 1042884
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
import json | ||
import pandas as pd | ||
from collections import OrderedDict | ||
|
||
tasks_path = 'tasks/' | ||
meta = pd.read_csv("Natural Instructions V2 Exps - tasks review 0323 (final).csv").values | ||
key_order = ("Contributors","Source","URL","Categories","Reasoning","Definition","Input_language","Output_language","Instruction_language","Domains","Positive Examples","Negative Examples","Instances") | ||
|
||
def ordered(d, key_order): | ||
return OrderedDict([(key, d[key]) for key in key_order]) | ||
|
||
for row in range(len(meta)): | ||
file = meta[row][0] + '.json' | ||
file_path = tasks_path + file | ||
with open(file_path, 'r') as f: | ||
try: | ||
data = json.load(f) | ||
except: | ||
with open(file_path, 'r', encoding='utf-8') as f: | ||
data = json.load(f) | ||
|
||
data['Categories'] = [meta[row][5]] | ||
data['Source'] = [meta[row][2]] | ||
data['URL'] = [meta[row][3]] | ||
|
||
data = ordered(data, key_order) | ||
with open(file_path, 'w', encoding='utf-8') as outfile: | ||
json.dump(data, outfile, indent=4,ensure_ascii=False) |