From c638aa00fa7fa986fa0ceb1078599d2f8675e91a Mon Sep 17 00:00:00 2001 From: linxiaohui Date: Tue, 18 Apr 2017 10:22:20 +0800 Subject: [PATCH] Python 3 Compatible --- pytagcloud/__init__.py | 2 +- pytagcloud/lang/counter.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pytagcloud/__init__.py b/pytagcloud/__init__.py index 760dbeb..1a512d6 100755 --- a/pytagcloud/__init__.py +++ b/pytagcloud/__init__.py @@ -385,7 +385,7 @@ def create_html_data(tags, color_map = {} for color_index, tag in enumerate(tags): - if not color_map.has_key(tag['color']): + if tag['color'] not in color_map: color_name = "c%d" % color_index hslcolor = colorsys.rgb_to_hls(tag['color'][0] / 255.0, tag['color'][1] / 255.0, diff --git a/pytagcloud/lang/counter.py b/pytagcloud/lang/counter.py index 693b0ba..c773b85 100644 --- a/pytagcloud/lang/counter.py +++ b/pytagcloud/lang/counter.py @@ -9,7 +9,7 @@ def get_tag_counts(text): Search tags in a given text. The language detection is based on stop lists. This implementation is inspired by https://github.com/jdf/cue.language. Thanks Jonathan Feinberg. """ - words = map(lambda x:x.lower(), re.findall(r"[\w']+", text, re.UNICODE)) + words = [x.lower() for x in re.findall(r"[\w']+", text, re.UNICODE)] s = StopWords() s.load_language(s.guess(words)) @@ -20,5 +20,5 @@ def get_tag_counts(text): if not s.is_stop_word(word) and len(word) > 1: counted[word] += 1 - return sorted(counted.iteritems(), key=itemgetter(1), reverse=True) + return sorted(counted.items(), key=itemgetter(1), reverse=True)