jordimas commited on
Commit
8fcfb0d
1 Parent(s): 2dce94c

Update labels

Browse files
Files changed (2) hide show
  1. config.json +12 -12
  2. 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": "LABEL_0",
16
- "1": "LABEL_1",
17
- "2": "LABEL_2",
18
- "3": "LABEL_3",
19
- "4": "LABEL_4",
20
- "5": "LABEL_5"
21
  },
22
  "initializer_range": 0.02,
23
  "intermediate_size": 3072,
24
  "label2id": {
25
- "LABEL_0": 0,
26
- "LABEL_1": 1,
27
- "LABEL_2": 2,
28
- "LABEL_3": 3,
29
- "LABEL_4": 4,
30
- "LABEL_5": 5
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)