ag2435 commited on
Commit
e899662
·
1 Parent(s): 21828d5

removed indents

Browse files
all2023/val.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:791d41446d57c53220d6b9a17324455ec4456c2f99d0a866624ae88707580e7c
3
- size 276804917
 
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:0410cf07331a5a337e268b3cbd516194e67b4d808c33813fc3771076ceac34f8
3
- size 216928959
 
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:4b9d8350587ecbea3a6ed80e386c2e12f01983c02dc69947f14cdbb3edaba92c
3
- size 863959698
 
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:604e83967f955123d5b1108dc1f033d19254c57974c836b80d3206a9ac381a44
3
- size 861534750
 
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:f8c6a3670aa07476c00783b6478fed26a766f63d077a972052d182b06a2a2980
3
- size 3413790835
 
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", indent=2)
97
  else:
98
- df.astype(str).to_json(save_path, lines=True, orient="records", mode='a', indent=2)
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
- # convert all columns to string per huggingface requirements
 
 
 
 
 
 
 
 
 
 
94
  if i == 0:
95
- df.astype(str).to_json(save_path, lines=True, orient="records", indent=2)
96
  else:
97
- df.astype(str).to_json(save_path, lines=True, orient="records", mode='a', indent=2)
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
  # %%