ag2435 commited on
Commit
131c65a
·
1 Parent(s): 19a4c0f

removed rows with empty fulltext

Browse files
Files changed (2) hide show
  1. all2023/val.json +2 -2
  2. preprocess_all2023_v2.py +9 -8
all2023/val.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2e54e8243728503f08cc209967466852e2e2d478ff959cc8609acc270ffe4c04
3
- size 13920109540
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4186a5287defbe55cb14b48b96a9d42630b623e645f65a65e18bfa12d4f9bfcb
3
+ size 13917099843
preprocess_all2023_v2.py CHANGED
@@ -101,7 +101,7 @@ def get_fulltext(row):
101
 
102
  count_orig = []
103
  count_isvalid = []
104
- count_isna = []
105
  # Ignore all quotes by setting quoting=3 (corresponds to csv.QUOTE_NONE)
106
  for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=10, dtype=str, quoting=3))):
107
  count_orig.append( len(original_df) )
@@ -122,7 +122,8 @@ for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=
122
  # drop `categories` column
123
  df = df.drop(columns=['categories'])
124
  # print number of rows where fulltext is not None
125
- count_isna.append( df['fulltext'].isna().sum() )
 
126
 
127
  # convert all columns to string per huggingface requirements
128
  if i == 0:
@@ -131,10 +132,10 @@ for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=
131
  df.to_json(save_path, lines=True, orient="records", mode='a')
132
 
133
  print("Saved to: ", save_path)
134
- # df_err = pd.DataFrame({
135
- # 'orig': count_orig,
136
- # 'isvalid': count_isvalid,
137
- # 'isna': count_isna
138
- # })
139
- # df_err.to_csv(f"error_log.csv", index=False)
140
  # %%
 
101
 
102
  count_orig = []
103
  count_isvalid = []
104
+ count_hasfulltext = []
105
  # Ignore all quotes by setting quoting=3 (corresponds to csv.QUOTE_NONE)
106
  for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=10, dtype=str, quoting=3))):
107
  count_orig.append( len(original_df) )
 
122
  # drop `categories` column
123
  df = df.drop(columns=['categories'])
124
  # print number of rows where fulltext is not None
125
+ df = df.dropna(subset=['fulltext'])
126
+ count_hasfulltext.append( len(df) )
127
 
128
  # convert all columns to string per huggingface requirements
129
  if i == 0:
 
132
  df.to_json(save_path, lines=True, orient="records", mode='a')
133
 
134
  print("Saved to: ", save_path)
135
+ df_err = pd.DataFrame({
136
+ 'orig': count_orig,
137
+ 'isvalid': count_isvalid,
138
+ 'hasfulltext': count_hasfulltext,
139
+ })
140
+ df_err.to_csv(f"error_log.csv", index=False)
141
  # %%