Skip to content

Commit 108a266

Browse files
authored
add encoding in duee, duie (#564)
1 parent 6305721 commit 108a266

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

examples/information_extraction/DuEE/classifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(self, data_path, tag_path):
133133

134134
def _read_tsv(self, input_file, quotechar=None):
135135
"""Reads a tab separated value file."""
136-
with open(input_file, "r") as f:
136+
with open(input_file, "r", encoding="UTF-8") as f:
137137
reader = csv.reader(f, delimiter="\t", quotechar=quotechar)
138138
headers = next(reader)
139139
text_indices = [

examples/information_extraction/DuIE/data_loader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ def from_file(cls,
259259

260260
input_ids, seq_lens, tok_to_orig_start_index, tok_to_orig_end_index, labels = (
261261
[] for _ in range(5))
262-
dataset_scale = sum(1 for line in open(file_path, 'r'))
262+
dataset_scale = sum(1 for line in open(
263+
file_path, 'r', encoding="UTF-8"))
263264
logger.info("Preprocessing data, loaded from %s" % file_path)
264265
with open(file_path, "r", encoding="utf-8") as fp:
265266
lines = fp.readlines()

0 commit comments

Comments
 (0)