Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 Compatible #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytagcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pytagcloud/lang/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)