From 0314cbf4d6e6fe4cdf54f3dbf464ddad0cfc1253 Mon Sep 17 00:00:00 2001 From: William Clifford Date: Fri, 18 Sep 2015 00:47:16 -0700 Subject: [PATCH] Expect case normalized words Ruby, Elixir, Clojure, and others expect words to be normalized in some way so that "Go", "go", "GO" are not considered different words. --- word-count/example.py | 2 +- word-count/word_count_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/word-count/example.py b/word-count/example.py index 367f2d2205b..121268dad03 100644 --- a/word-count/example.py +++ b/word-count/example.py @@ -5,4 +5,4 @@ def word_count(text): """Return a Counter object that maps from the words contained in the phrase to their respective counts """ - return Counter(text.split()) + return Counter(text.lower().split()) diff --git a/word-count/word_count_test.py b/word-count/word_count_test.py index c0dc141493e..0f656c11ac4 100644 --- a/word-count/word_count_test.py +++ b/word-count/word_count_test.py @@ -36,8 +36,8 @@ def test_include_numbers(self): def test_mixed_case(self): self.assertEqual( - {'go': 1, 'Go': 1, 'GO': 1}, - word_count('go Go GO') + [3], + list(word_count('go Go GO').values()) ) def test_multiple_spaces(self):