Skip to content

Commit 02b4721

Browse files
Merge pull request #17 from HanYuanHsu/main
added utf-8
2 parents 4d71be6 + 3ee6788 commit 02b4721

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

eval/of_hfmodel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def main():
6969
max_tokens = cfg["max_tokens"]
7070
split = cfg["split"]
7171

72-
with open(few_shot_prompt_path) as f:
72+
with open(few_shot_prompt_path, encoding='utf-8') as f:
7373
FEW_SHOT_PROMPT = f.read()
7474

7575
if os.path.isdir(save_dir):
@@ -113,17 +113,17 @@ def main():
113113
step[OUT_KEY] = text_out
114114
step['prompt'] = prompt
115115

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:
117117
record = json.dumps(step)
118118
f.write(record+"\n")
119119

120120
# 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:
122122
data = ndjson.load(f)
123123

124124
bleu = calc_bleu(data, OUT_KEY, ref_key)
125125

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:
127127
json.dump({"bleu": bleu}, f)
128128

129129
make_readable(save_dir, save_file, ref_key)

0 commit comments

Comments
 (0)