Skip to content

Commit d1d441d

Browse files
bpopetersvince62s
authored andcommitted
fix behavior with shard_size == 0 (#1215)
1 parent bdd64fd commit d1d441d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

onmt/utils/misc.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
def split_corpus(path, shard_size):
1010
with codecs.open(path, "r", encoding="utf-8") as f:
11-
while True:
12-
shard = list(islice(f, shard_size))
13-
if not shard:
14-
break
15-
yield shard
11+
if shard_size <= 0:
12+
yield f.readlines()
13+
else:
14+
while True:
15+
shard = list(islice(f, shard_size))
16+
if not shard:
17+
break
18+
yield shard
1619

1720

1821
def aeq(*args):

0 commit comments

Comments
 (0)