Skip to content

Commit

Permalink
fix stop_words conversion to set (#458)
Browse files Browse the repository at this point in the history
* fix error that copied the original `stop_words` argument in Field constructor
  • Loading branch information
artemisart authored and mttk committed Oct 23, 2018
1 parent 758d356 commit 98de87c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions torchtext/data/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,10 @@ def __init__(self, sequential=True, use_vocab=True, init_token=None,
self.pad_token = pad_token if self.sequential else None
self.pad_first = pad_first
self.truncate_first = truncate_first
if stop_words is not None:
try:
self.stop_words = set(stop_words)
except TypeError:
raise ValueError("Stop words must be convertible to a set")
else:
self.stop_words = stop_words
self.stop_words = stop_words
try:
self.stop_words = set(stop_words) if stop_words is not None else None
except TypeError:
raise ValueError("Stop words must be convertible to a set")
self.is_target = is_target

def __getstate__(self):
Expand Down

0 comments on commit 98de87c

Please sign in to comment.