Skip to content

Commit

Permalink
Merge pull request #438 from NaanProphet/stopwords-unicode
Browse files Browse the repository at this point in the history
unicode stopwords files now supported in python 2.7
  • Loading branch information
amueller committed Sep 24, 2018
2 parents 61404c5 + 46529eb commit 6135bc3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/test_wordcloud_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ def test_unicode_text_file():
assert len(text) == 16


def test_unicode_with_stopwords():
unicode_file = os.path.join(os.path.dirname(__file__), "unicode_text.txt")
stopwords_file = os.path.join(os.path.dirname(__file__), "unicode_stopwords.txt")
args, text, image_file = cli.parse_args(['--text', unicode_file, '--stopwords', stopwords_file])

# expect the unicode character from stopwords file was correctly read in
assert u'\u304D' in args['stopwords']


def test_cli_writes_image(tmpdir, tmp_text_file):
# ensure writing works with all python versions
tmp_image_file = tmpdir.join("word_cloud.png")
Expand Down
1 change: 1 addition & 0 deletions test/unicode_stopwords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2 changes: 1 addition & 1 deletion wordcloud/wordcloud_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def parse_args(arguments):

if args['stopwords']:
with args.pop('stopwords') as f:
args['stopwords'] = set(map(str.strip, f.readlines()))
args['stopwords'] = set(map(lambda l: l.strip(), f.readlines()))

if args['mask']:
mask = args.pop('mask')
Expand Down

0 comments on commit 6135bc3

Please sign in to comment.