|
import shutil |
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
print("Convert model labels to human readable") |
|
|
|
source_file = 'config.json' |
|
old_file = 'config.json.bak' |
|
|
|
shutil.copyfile(source_file, old_file) |
|
|
|
LABEL_TO_CHAR = { |
|
"LABEL_0" : "0", |
|
"LABEL_1" : ".", |
|
"LABEL_2" : ",", |
|
"LABEL_3" : "?", |
|
"LABEL_4" : "-", |
|
"LABEL_5" : ":" |
|
} |
|
|
|
|
|
with open(old_file, 'r') as fp_input, open(source_file, 'w') as fp_output: |
|
lines = fp_input.readlines() |
|
for line in lines: |
|
for label in LABEL_TO_CHAR.keys(): |
|
line = line.replace(label, LABEL_TO_CHAR[label]) |
|
|
|
fp_output.write(line) |
|
|