You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I tried the example on Python 3.5 and realized it was not compatible. In order to make it function on this version I modified the pytagcloud/lang/counter.pyfile to look like this
# -*- coding: utf-8 -*-importrefrompytagcloud.lang.stopwordsimportStopWordsfromoperatorimportitemgetterdefget_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))# the line above doesn't work on python 3.5s=StopWords()
s.load_language(s.guess(map(lambdax:x.lower(), re.findall(r'\w+', text, re.UNICODE))))
counted= {}
forwordinmap(lambdax:x.lower(), re.findall(r'\w+', text, re.UNICODE)):
ifnots.is_stop_word(word) andlen(word) >1:
ifwordincounted: #no has_key() method on python 3, use in insteadcounted[word] +=1else:
counted[word] =1returnsorted(counted.items(), key=itemgetter(1), reverse=True)
I leave this here because I did not find a branch for python 3 and maybe someone could find it useful
The text was updated successfully, but these errors were encountered:
In order to be able to find this easier, here is a corresponding error message:
AttributeError Traceback (most recent call last)
Cell In[2], line 7
2 from pytagcloud.lang.counter import get_tag_counts
4 YOUR_TEXT = "A tag cloud is a visual representation for text data, typically
5 used to depict keyword metadata on websites, or to visualize free form text."
----> 7 tags = make_tags(get_tag_counts(YOUR_TEXT), maxsize=80)
9 create_tag_image(tags, 'cloud_large.png', size=(900, 600), fontname='Lobster')
11 import webbrowser
Hello, I tried the example on Python 3.5 and realized it was not compatible. In order to make it function on this version I modified the
pytagcloud/lang/counter.py
file to look like thisI leave this here because I did not find a branch for python 3 and maybe someone could find it useful
The text was updated successfully, but these errors were encountered: