Update labels
Browse files- config.json +12 -12
- convert-labels.py +29 -0
config.json
CHANGED
@@ -12,22 +12,22 @@
|
|
12 |
"hidden_dropout_prob": 0.1,
|
13 |
"hidden_size": 768,
|
14 |
"id2label": {
|
15 |
-
"0": "
|
16 |
-
"1": "
|
17 |
-
"2": "
|
18 |
-
"3": "
|
19 |
-
"4": "
|
20 |
-
"5": "
|
21 |
},
|
22 |
"initializer_range": 0.02,
|
23 |
"intermediate_size": 3072,
|
24 |
"label2id": {
|
25 |
-
"
|
26 |
-
"
|
27 |
-
"
|
28 |
-
"
|
29 |
-
"
|
30 |
-
"
|
31 |
},
|
32 |
"layer_norm_eps": 1e-05,
|
33 |
"max_position_embeddings": 514,
|
|
|
12 |
"hidden_dropout_prob": 0.1,
|
13 |
"hidden_size": 768,
|
14 |
"id2label": {
|
15 |
+
"0": "0",
|
16 |
+
"1": ".",
|
17 |
+
"2": ",",
|
18 |
+
"3": "?",
|
19 |
+
"4": "-",
|
20 |
+
"5": ":"
|
21 |
},
|
22 |
"initializer_range": 0.02,
|
23 |
"intermediate_size": 3072,
|
24 |
"label2id": {
|
25 |
+
"0": 0,
|
26 |
+
".": 1,
|
27 |
+
",": 2,
|
28 |
+
"?": 3,
|
29 |
+
"-": 4,
|
30 |
+
":": 5
|
31 |
},
|
32 |
"layer_norm_eps": 1e-05,
|
33 |
"max_position_embeddings": 514,
|
convert-labels.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import shutil
|
2 |
+
|
3 |
+
|
4 |
+
if __name__ == "__main__":
|
5 |
+
|
6 |
+
print("Convert model labels to human readable")
|
7 |
+
|
8 |
+
source_file = 'config.json'
|
9 |
+
old_file = 'config.json.bak'
|
10 |
+
|
11 |
+
shutil.copyfile(source_file, old_file)
|
12 |
+
|
13 |
+
LABEL_TO_CHAR = {
|
14 |
+
"LABEL_0" : "0",
|
15 |
+
"LABEL_1" : ".",
|
16 |
+
"LABEL_2" : ",",
|
17 |
+
"LABEL_3" : "?",
|
18 |
+
"LABEL_4" : "-",
|
19 |
+
"LABEL_5" : ":"
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
with open(old_file, 'r') as fp_input, open(source_file, 'w') as fp_output:
|
24 |
+
lines = fp_input.readlines()
|
25 |
+
for line in lines:
|
26 |
+
for label in LABEL_TO_CHAR.keys():
|
27 |
+
line = line.replace(label, LABEL_TO_CHAR[label])
|
28 |
+
|
29 |
+
fp_output.write(line)
|