reupload data with updated aliases
Browse files- minor/test.json +2 -2
- minor/train.json +2 -2
- preprocess.sh +9 -9
- preprocess_all2023.py +1 -1
- preprocess_major_minor.py +1 -1
- util_preprocess.py +9 -4
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:7ca3a4ac413f1ed09b4072aa40a7884291cb0a6de5f64b2d876010b52a323a7d
|
3 |
+
size 1600703700
|
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:c2114c3849cb102be81c1a7e61461d93d2d79336cbb37fd38fe49e6b4e7a1c5b
|
3 |
+
size 6419078155
|
preprocess.sh
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
# # test
|
2 |
# python preprocess_major_minor.py -d major -s test
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
# all 2023 corpus
|
13 |
-
python preprocess_all2023.py
|
|
|
1 |
# # test
|
2 |
# python preprocess_major_minor.py -d major -s test
|
3 |
|
4 |
+
# major/minor cats
|
5 |
+
for dataset in major minor
|
6 |
+
do
|
7 |
+
for split in train test
|
8 |
+
do
|
9 |
+
python preprocess_major_minor.py -d $dataset -s $split
|
10 |
+
done
|
11 |
+
done
|
12 |
# all 2023 corpus
|
13 |
+
python preprocess_all2023.py
|
preprocess_all2023.py
CHANGED
@@ -23,7 +23,7 @@ parser = ArgumentParser()
|
|
23 |
# parser.add_argument("--dataset", "-d", type=str, default="minor")
|
24 |
# parser.add_argument("--split", "-s", type=str, default="val")
|
25 |
parser.add_argument("--output_path", "-op", type=str, default="./")
|
26 |
-
parser.add_argument("--input_path", "-ip", type=str, default="./",
|
27 |
help="Path to the input data files")
|
28 |
args, opt = parser.parse_known_args()
|
29 |
|
|
|
23 |
# parser.add_argument("--dataset", "-d", type=str, default="minor")
|
24 |
# parser.add_argument("--split", "-s", type=str, default="val")
|
25 |
parser.add_argument("--output_path", "-op", type=str, default="./")
|
26 |
+
parser.add_argument("--input_path", "-ip", type=str, default="./data",
|
27 |
help="Path to the input data files")
|
28 |
args, opt = parser.parse_known_args()
|
29 |
|
preprocess_major_minor.py
CHANGED
@@ -23,7 +23,7 @@ parser = ArgumentParser()
|
|
23 |
parser.add_argument("--dataset", "-d", type=str, default="minor")
|
24 |
parser.add_argument("--split", "-s", type=str, default="train")
|
25 |
parser.add_argument("--output_path", "-op", type=str, default="./")
|
26 |
-
parser.add_argument("--input_path", "-ip", type=str, default="./",
|
27 |
help="Path to the input data files")
|
28 |
args, opt = parser.parse_known_args()
|
29 |
|
|
|
23 |
parser.add_argument("--dataset", "-d", type=str, default="minor")
|
24 |
parser.add_argument("--split", "-s", type=str, default="train")
|
25 |
parser.add_argument("--output_path", "-op", type=str, default="./")
|
26 |
+
parser.add_argument("--input_path", "-ip", type=str, default="./data",
|
27 |
help="Path to the input data files")
|
28 |
args, opt = parser.parse_known_args()
|
29 |
|
util_preprocess.py
CHANGED
@@ -20,11 +20,16 @@ def preprocess_primary_secondary(df):
|
|
20 |
# split string to list by space
|
21 |
for subfield in s.split():
|
22 |
# substitute aliases
|
23 |
-
|
|
|
|
|
24 |
# ignore secondary subfield if one of the ignored categories
|
25 |
-
if
|
26 |
continue
|
27 |
-
|
|
|
|
|
|
|
28 |
# return list of subfields
|
29 |
return subfields
|
30 |
|
@@ -35,6 +40,6 @@ def preprocess_primary_secondary(df):
|
|
35 |
# assert that each primary subfield is in SUBFIELD_MAP
|
36 |
assert all(df['primary_subfield'].isin(SUBFIELD_MAP.keys()))
|
37 |
# assert that each secondary subfield is in SUBFIELD_MAP
|
38 |
-
assert all(df['secondary_subfield'].apply(lambda x: all(subfield in SUBFIELD_MAP.keys() for subfield in x)))
|
39 |
# return preprocessed dataframe
|
40 |
return df
|
|
|
20 |
# split string to list by space
|
21 |
for subfield in s.split():
|
22 |
# substitute aliases
|
23 |
+
new_subfield = substitute_aliases(subfield)
|
24 |
+
if new_subfield == 'cs.NA':
|
25 |
+
print(f"Warning:25> Subfield {new_subfield} not in SUBFIELD_MAP")
|
26 |
# ignore secondary subfield if one of the ignored categories
|
27 |
+
if new_subfield in IGNORE:
|
28 |
continue
|
29 |
+
# assert new_subfield in SUBFIELD_MAP.keys(), f"Subfield {new_subfield} not in SUBFIELD_MAP"
|
30 |
+
if new_subfield not in SUBFIELD_MAP.keys():
|
31 |
+
print(f"Warning: Subfield {new_subfield} not in SUBFIELD_MAP")
|
32 |
+
subfields.append(new_subfield)
|
33 |
# return list of subfields
|
34 |
return subfields
|
35 |
|
|
|
40 |
# assert that each primary subfield is in SUBFIELD_MAP
|
41 |
assert all(df['primary_subfield'].isin(SUBFIELD_MAP.keys()))
|
42 |
# assert that each secondary subfield is in SUBFIELD_MAP
|
43 |
+
# assert all(df['secondary_subfield'].apply(lambda x: all([subfield in SUBFIELD_MAP.keys() for subfield in x])))
|
44 |
# return preprocessed dataframe
|
45 |
return df
|