removed indents
Browse files- all2023/val.json +2 -2
- major/test.json +2 -2
- major/train.json +2 -2
- minor/test.json +2 -2
- minor/train.json +2 -2
- preprocess_all2023.py +2 -2
- preprocess_major_minor.py +19 -3
all2023/val.json
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25f9bbb9c7b0972426b0153e7fc4c39f4200db38c1e2914062014b7903647d96
|
3 |
+
size 270343587
|
major/test.json
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f479ccd1901ebd967a64a17b6ec9934501629f5caa7bc88b9fb8ca512f54011a
|
3 |
+
size 216694822
|
major/train.json
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:258b7304c47a12f0c035657831926953207399fccbcfa9018817b514a2cbff7b
|
3 |
+
size 863033790
|
minor/test.json
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fb4a6091612f356e4c6184bae2468d4ac5f5fc41729d947b1eaec82017b06ed5
|
3 |
+
size 860652299
|
minor/train.json
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:93e6352bf9f03225a256f0e44a83b4de3b608b4024ac78ba3b808e9b0db223b3
|
3 |
+
size 3410271223
|
preprocess_all2023.py
CHANGED
@@ -93,8 +93,8 @@ for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=
|
|
93 |
|
94 |
# convert all columns to string per huggingface requirements
|
95 |
if i == 0:
|
96 |
-
df.astype(str).to_json(save_path, lines=True, orient="records"
|
97 |
else:
|
98 |
-
df.astype(str).to_json(save_path, lines=True, orient="records", mode='a'
|
99 |
|
100 |
# %%
|
|
|
93 |
|
94 |
# convert all columns to string per huggingface requirements
|
95 |
if i == 0:
|
96 |
+
df.astype(str).to_json(save_path, lines=True, orient="records")
|
97 |
else:
|
98 |
+
df.astype(str).to_json(save_path, lines=True, orient="records", mode='a')
|
99 |
|
100 |
# %%
|
preprocess_major_minor.py
CHANGED
@@ -74,6 +74,12 @@ os.makedirs(save_dir, exist_ok=True)
|
|
74 |
save_path = os.path.join(save_dir, f"{split}.json")
|
75 |
print("Reading from file: ", file_path)
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
for i, original_df in tqdm(enumerate(pd.read_json(file_path, lines=True, chunksize=10**4))):
|
78 |
# print(f"Chunk {i+1}")
|
79 |
# print("original columns: ", original_df.columns)
|
@@ -90,10 +96,20 @@ for i, original_df in tqdm(enumerate(pd.read_json(file_path, lines=True, chunksi
|
|
90 |
if df['primary_subfield'].isin(CATEGORY_ALIASES.keys()).sum():
|
91 |
ValueError("IMPLEMENT CODE TO CHANGE CATEGORY_ALIASES ")
|
92 |
|
93 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
if i == 0:
|
95 |
-
df.astype(str).to_json(save_path, lines=True, orient="records"
|
96 |
else:
|
97 |
-
df.astype(str).to_json(save_path, lines=True, orient="records", mode='a'
|
98 |
|
99 |
# %%
|
|
|
74 |
save_path = os.path.join(save_dir, f"{split}.json")
|
75 |
print("Reading from file: ", file_path)
|
76 |
|
77 |
+
# # delete file if it exists
|
78 |
+
# if os.path.exists(save_path):
|
79 |
+
# print("Overwriting existing file: ", save_path)
|
80 |
+
# os.remove(save_path)
|
81 |
+
|
82 |
+
# with open(save_path, 'a') as f:
|
83 |
for i, original_df in tqdm(enumerate(pd.read_json(file_path, lines=True, chunksize=10**4))):
|
84 |
# print(f"Chunk {i+1}")
|
85 |
# print("original columns: ", original_df.columns)
|
|
|
96 |
if df['primary_subfield'].isin(CATEGORY_ALIASES.keys()).sum():
|
97 |
ValueError("IMPLEMENT CODE TO CHANGE CATEGORY_ALIASES ")
|
98 |
|
99 |
+
# # preprocess the chunk here
|
100 |
+
# df_chunk = df.astype(str)
|
101 |
+
# # convert the DataFrame to a JSON string
|
102 |
+
# json_str = df_chunk.to_json(orient='records', lines=True)
|
103 |
+
|
104 |
+
# # write the JSON string to file
|
105 |
+
# f.write(json_str)
|
106 |
+
|
107 |
+
# # add a newline character after each chunk except the last one
|
108 |
+
# # if i != num_chunks - 1:
|
109 |
+
# f.write('\n')
|
110 |
if i == 0:
|
111 |
+
df.astype(str).to_json(save_path, lines=True, orient="records")
|
112 |
else:
|
113 |
+
df.astype(str).to_json(save_path, lines=True, orient="records", mode='a')
|
114 |
|
115 |
# %%
|