@@ -69,7 +69,7 @@ def main():
69
69
max_tokens = cfg ["max_tokens" ]
70
70
split = cfg ["split" ]
71
71
72
- with open (few_shot_prompt_path ) as f :
72
+ with open (few_shot_prompt_path , encoding = 'utf-8' ) as f :
73
73
FEW_SHOT_PROMPT = f .read ()
74
74
75
75
if os .path .isdir (save_dir ):
@@ -113,17 +113,17 @@ def main():
113
113
step [OUT_KEY ] = text_out
114
114
step ['prompt' ] = prompt
115
115
116
- with open (os .path .join (save_dir , save_file ), "a+" ) as f :
116
+ with open (os .path .join (save_dir , save_file ), mode = "a+" , encoding = 'utf-8' ) as f :
117
117
record = json .dumps (step )
118
118
f .write (record + "\n " )
119
119
120
120
# calculates bleu
121
- with open (os .path .join (save_dir , save_file )) as f :
121
+ with open (os .path .join (save_dir , save_file ), encoding = 'utf-8' ) as f :
122
122
data = ndjson .load (f )
123
123
124
124
bleu = calc_bleu (data , OUT_KEY , ref_key )
125
125
126
- with open (os .path .join (save_dir , "metrics.json" ), "w" ) as f :
126
+ with open (os .path .join (save_dir , "metrics.json" ), mode = "w" , encoding = 'utf-8' ) as f :
127
127
json .dump ({"bleu" : bleu }, f )
128
128
129
129
make_readable (save_dir , save_file , ref_key )
0 commit comments