updated all2023 dataset
Browse files- README.md +10 -5
- all2023/val.json +2 -2
- preprocess_all2023_v2.py +19 -0
- util_preprocess.py +3 -1
README.md
CHANGED
@@ -33,7 +33,13 @@ Old terminology to standardized terminology translation:
|
|
33 |
|
34 |
Original data: https://www.dropbox.com/scl/fo/wwu0ifghw4sco09g67frb/h?rlkey=6ddg3yab9la3zeddvmnsfktxq&e=1&dl=0
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
## Set up dependencies
|
39 |
|
@@ -51,8 +57,8 @@ Transform raw data into JSON format:
|
|
51 |
```
|
52 |
# major/minor cats data
|
53 |
python preprocess_major_minor.py -d <DATASET NAME> -s <SPLIT> -op <PATH TO SAVE PREPROCESSED DATA>
|
54 |
-
# all 2023 corpus (
|
55 |
-
python
|
56 |
```
|
57 |
|
58 |
Additional data checks:
|
@@ -70,5 +76,4 @@ python test_paper_id.py
|
|
70 |
|
71 |
<!-- ## Todo
|
72 |
|
73 |
-
- Can we
|
74 |
-
- Can we incorporate additional metadata (e.g., authors)? -->
|
|
|
33 |
|
34 |
Original data: https://www.dropbox.com/scl/fo/wwu0ifghw4sco09g67frb/h?rlkey=6ddg3yab9la3zeddvmnsfktxq&e=1&dl=0
|
35 |
|
36 |
+
Configurations:
|
37 |
+
|
38 |
+
**Minor (default)**: Dataset of papers between 2010 and 2020 (with some pre-2010 papers) with balanced primary subfields.
|
39 |
+
|
40 |
+
**Major**: Dataset of papers between 2010 and 2020 (with some pre-2010 papers) with unbalanced primary subfields to better represent the true distribution of primary categories, which is dominated by a few subfields. Note that the distribution of major subfields is still truncated.
|
41 |
+
|
42 |
+
**All 2023**: All papers published in 2023.
|
43 |
|
44 |
## Set up dependencies
|
45 |
|
|
|
57 |
```
|
58 |
# major/minor cats data
|
59 |
python preprocess_major_minor.py -d <DATASET NAME> -s <SPLIT> -op <PATH TO SAVE PREPROCESSED DATA>
|
60 |
+
# all 2023 corpus (full text)
|
61 |
+
python preprocess_all2023_v2.py
|
62 |
```
|
63 |
|
64 |
Additional data checks:
|
|
|
76 |
|
77 |
<!-- ## Todo
|
78 |
|
79 |
+
- Can we incorporate additional metadata (e.g., authors)? Note: author names are contained in the full text-->
|
|
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:2e54e8243728503f08cc209967466852e2e2d478ff959cc8609acc270ffe4c04
|
3 |
+
size 13920109540
|
preprocess_all2023_v2.py
CHANGED
@@ -13,6 +13,8 @@
|
|
13 |
# language: python
|
14 |
# name: python3
|
15 |
# ---
|
|
|
|
|
16 |
|
17 |
# %%
|
18 |
#
|
@@ -38,6 +40,7 @@ input_path = args.input_path
|
|
38 |
#
|
39 |
import pandas as pd
|
40 |
import os
|
|
|
41 |
from tqdm import tqdm
|
42 |
from util_preprocess import preprocess_primary_secondary
|
43 |
|
@@ -96,8 +99,12 @@ def get_fulltext(row):
|
|
96 |
fulltext = None
|
97 |
return fulltext
|
98 |
|
|
|
|
|
|
|
99 |
# Ignore all quotes by setting quoting=3 (corresponds to csv.QUOTE_NONE)
|
100 |
for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=10, dtype=str, quoting=3))):
|
|
|
101 |
# set non-existent features to empty string
|
102 |
for feature in FEATURES:
|
103 |
if feature not in original_df.columns:
|
@@ -108,8 +115,14 @@ for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=
|
|
108 |
original_df.loc[:, 'secondary_subfield'] = original_df['categories']
|
109 |
# Apply preprocessing rules
|
110 |
df = preprocess_primary_secondary(original_df)
|
|
|
|
|
111 |
# Get fulltext for each paper from .txt files
|
112 |
df.loc[:, 'fulltext'] = df.apply(get_fulltext, axis=1)
|
|
|
|
|
|
|
|
|
113 |
|
114 |
# convert all columns to string per huggingface requirements
|
115 |
if i == 0:
|
@@ -118,4 +131,10 @@ for i, original_df in tqdm(enumerate(pd.read_csv(file_path, sep='\t', chunksize=
|
|
118 |
df.to_json(save_path, lines=True, orient="records", mode='a')
|
119 |
|
120 |
print("Saved to: ", save_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
# %%
|
|
|
13 |
# language: python
|
14 |
# name: python3
|
15 |
# ---
|
16 |
+
# %% [markdown]
|
17 |
+
# Script for converting all 2023 corpus (with full text) to json format.
|
18 |
|
19 |
# %%
|
20 |
#
|
|
|
40 |
#
|
41 |
import pandas as pd
|
42 |
import os
|
43 |
+
import sys
|
44 |
from tqdm import tqdm
|
45 |
from util_preprocess import preprocess_primary_secondary
|
46 |
|
|
|
99 |
fulltext = None
|
100 |
return fulltext
|
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) )
|
108 |
# set non-existent features to empty string
|
109 |
for feature in FEATURES:
|
110 |
if feature not in original_df.columns:
|
|
|
115 |
original_df.loc[:, 'secondary_subfield'] = original_df['categories']
|
116 |
# Apply preprocessing rules
|
117 |
df = preprocess_primary_secondary(original_df)
|
118 |
+
|
119 |
+
count_isvalid.append( len(df) )
|
120 |
# Get fulltext for each paper from .txt files
|
121 |
df.loc[:, 'fulltext'] = df.apply(get_fulltext, axis=1)
|
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 |
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 |
# %%
|
util_preprocess.py
CHANGED
@@ -13,7 +13,9 @@ def preprocess_primary_secondary(df):
|
|
13 |
# substitute aliases for primary subfield
|
14 |
df.loc[:, 'primary_subfield'] = df['primary_subfield'].apply(substitute_aliases)
|
15 |
# ignore row if primary subfield is one of the ignored categories
|
16 |
-
|
|
|
|
|
17 |
|
18 |
def preprocess_secondary(s):
|
19 |
subfields = []
|
|
|
13 |
# substitute aliases for primary subfield
|
14 |
df.loc[:, 'primary_subfield'] = df['primary_subfield'].apply(substitute_aliases)
|
15 |
# ignore row if primary subfield is one of the ignored categories
|
16 |
+
ignore_rows = df['primary_subfield'].isin(IGNORE)
|
17 |
+
df = df[~ignore_rows]
|
18 |
+
# print(f"Ignored {ignore_rows.sum()} rows with primary subfield in IGNORE")
|
19 |
|
20 |
def preprocess_secondary(s):
|
21 |
subfields = []
|