Skip to content

Commit c7d54f6

Browse files
authored
Week 07 get rid of randomness of Vocab.from_lines (yandexdataschool#383)
1 parent 16a7d31 commit c7d54f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

week07_seq2seq/voc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __len__(self):
2323
def from_lines(lines, bos="__BOS__", eos="__EOS__", sep=''):
2424
flat_lines = sep.join(list(lines))
2525
flat_lines = list(flat_lines.split(sep)) if sep else list(flat_lines)
26-
tokens = list(set(sep.join(flat_lines)))
26+
tokens = sorted(set(sep.join(flat_lines)))
2727
tokens = [t for t in tokens if t not in (bos, eos) and len(t) != 0]
2828
tokens = [bos, eos] + tokens
2929
return Vocab(tokens, bos, eos, sep)

0 commit comments

Comments
 (0)