本文整理汇总了Python中pytagcloud.lang.counter.get_tag_counts函数的典型用法代码示例。如果您正苦于以下问题:Python get_tag_counts函数的具体用法?Python get_tag_counts怎么用?Python get_tag_counts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_tag_counts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: wordcloud
def wordcloud(self,OVERALLTEXT,NEGATIVETEXT,POSITIVETEXT,test_output, font):
#Constants
overalltext = open(OVERALLTEXT, 'r')
negativetext = open(NEGATIVETEXT, 'r')
positivetext = open(POSITIVETEXT, 'r')
#Overall
tags = make_tags(get_tag_counts(overalltext.read())[:50],maxsize=90, minsize = 15)
for layout in LAYOUTS:
create_tag_image(tags,os.path.join(test_output, 'Overall_%s.png' % layout), size=(900,600),
background=(255, 255, 255), layout = layout, fontname = font, rectangular=True)
#Negative
tags = make_tags(get_tag_counts(negativetext.read())[:50], maxsize=90,minsize = 15, colors=COLOR_SCHEMES['audacity'])
for layout in LAYOUTS:
create_tag_image(tags, os.path.join(test_output, 'negative_%s.png' % layout),
size=(900,600), background=(205, 50, 50),
layout=layout, fontname = font)
#Positive
tags = make_tags(get_tag_counts(positivetext.read())[:50], maxsize=120, minsize = 25, colors=COLOR_SCHEMES['oldschool'])
for layout in LAYOUTS:
create_tag_image(tags, os.path.join(test_output, 'positive_%s.png' % layout),
size=(900,600), background=(0, 255, 15),
layout=layout, fontname = font)
开发者ID:emmadickson,项目名称:Bellevue-Data-Science-Project,代码行数:29,代码来源:Comment_Tools.py
示例2: get_tag_cloud
def get_tag_cloud(request, region_code):
# Get all tweets in the region
data_zone = DataZone.objects.get(code=region_code)
tweet_locations = TweetLocation.objects.filter(zone=data_zone)
body_text = ''
for x in tweet_locations:
body_text += x.tweet.body + ' '
tc = TagCloud()
body_text = tc.filter_body(body_text)
if body_text.strip() == '':
body_text = "Region Empty"
tags = make_tags(get_tag_counts(body_text)[:50], maxsize=50, colors=COLOR_SCHEMES['audacity'])
data = create_html_data(tags, (560,450), layout=LAYOUT_HORIZONTAL, fontname='PT Sans Regular')
context = {}
tags_template = '<li class="cnt" style="top: %(top)dpx; left: %(left)dpx; height: %(height)dpx;"><a class="tag %(cls)s" href="#%(tag)s" style="top: %(top)dpx;\
left: %(left)dpx; font-size: %(size)dpx; height: %(height)dpx; line-height:%(lh)dpx;">%(tag)s</a></li>'
context['tags'] = ''.join([tags_template % link for link in data['links']])
context['width'] = data['size'][0]
context['height'] = data['size'][1]
context['css'] = "".join("a.%(cname)s{color:%(normal)s;}a.%(cname)s:hover{color:%(hover)s;}" % {'cname':k, 'normal': v[0], 'hover': v[1]} for k,v in data['css'].items())
return render_to_response('tag_cloud.html', {'tags': context['tags'], 'css': context['css']})
开发者ID:camerongray1515,项目名称:ilwhack2014,代码行数:30,代码来源:views.py
示例3: make_cloud
def make_cloud(self, output_html):
keywords = KeywordManager().all()
text = ' '.join([kw.keyword for kw in keywords])
if output_html:
max_tags = 30
max_size = 42
else:
max_tags = 100
max_size = self.maxsize
tags = make_tags(get_tag_counts(text)[:max_tags], minsize=self.minsize,
maxsize=max_size)
if output_html:
size = (900, 300)
result = create_html_data(tags, size=size,
layout=LAYOUT_HORIZONTAL)
else:
#now = datetime.utcnow()
#filename = 'jcuwords/static/clouds/keyword-cloud-%s.png' % now.isoformat()
cloud = self.resolver.resolve('jcuwords:keyword-cloud.png')
filename = cloud.abspath()
size = (1024, 500)
create_tag_image(tags, filename, size=size,
fontname='IM Fell DW Pica',
layout=LAYOUT_MIX)
image_url = self.request.resource_url(None, 'keyword-cloud.png')
result = {'image': image_url}
return result
开发者ID:jcu-eresearch,项目名称:jcu.words,代码行数:31,代码来源:views.py
示例4: createTagCloud
def createTagCloud(self,wordline):
"""
Create tag cloud image
"""
wordstream = []
if wordline == '':
return False
wordsTokens = WhitespaceTokenizer().tokenize(wordline)
wordsTokens.remove(wordsTokens[0])
wordstream.append(' '.join(wordsTokens))
wordstream = ' '.join(wordstream)
thresh = self.wordCount
colorS = self.colorSchemes[self.color]
tags = make_tags(get_tag_counts(wordstream)[:thresh],\
minsize=3, maxsize=40,\
colors = COLOR_SCHEMES[colorS])
create_tag_image(tags, self.png,\
size=(960, 400),\
background=(255, 255, 255, 255),\
layout= LAYOUT_HORIZONTAL,\
fontname='Neuton')
return True
开发者ID:BloodD,项目名称:PyTopicM,代码行数:25,代码来源:wordCloudDraw.py
示例5: test_create_html_data
def test_create_html_data(self):
"""
HTML code sample
"""
tags = make_tags(get_tag_counts(self.hound.read())[:100], maxsize=120, colors=COLOR_SCHEMES['audacity'])
data = create_html_data(tags, (440,600), layout=LAYOUT_HORIZONTAL, fontname='PT Sans Regular')
template_file = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'web/template.html'), 'r')
html_template = Template(template_file.read())
context = {}
tags_template = '<li class="cnt" style="top: %(top)dpx; left: %(left)dpx; height: %(height)dpx;"><a class="tag %(cls)s" href="#%(tag)s" style="top: %(top)dpx;\
left: %(left)dpx; font-size: %(size)dpx; height: %(height)dpx; line-height:%(lh)dpx;">%(tag)s</a></li>'
context['tags'] = ''.join([tags_template % link for link in data['links']])
context['width'] = data['size'][0]
context['height'] = data['size'][1]
context['css'] = "".join("a.%(cname)s{color:%(normal)s;}\
a.%(cname)s:hover{color:%(hover)s;}" %
{'cname':k,
'normal': v[0],
'hover': v[1]}
for k,v in data['css'].items())
html_text = html_template.substitute(context)
html_file = open(os.path.join(self.test_output, 'cloud.html'), 'w')
html_file.write(html_text)
html_file.close()
开发者ID:johnlaudun,项目名称:PyTagCloud,代码行数:30,代码来源:tests.py
示例6: _create_image
def _create_image(self, text):
tag_counts = get_tag_counts(text)
if tag_counts is None:
sys.exit(-1)
if self._repeat_tags:
expanded_tag_counts = []
for tag in tag_counts:
expanded_tag_counts.append((tag[0], 5))
for tag in tag_counts:
expanded_tag_counts.append((tag[0], 2))
for tag in tag_counts:
expanded_tag_counts.append((tag[0], 1))
tag_counts = expanded_tag_counts
tags = make_tags(tag_counts, maxsize=150, colors=self._color_scheme)
path = os.path.join('/tmp/cloud_large.png')
if Gdk.Screen.height() < Gdk.Screen.width():
height = Gdk.Screen.height()
width = int(height * 4 / 3)
else:
width = Gdk.Screen.width()
height = int(width * 3 / 4)
if self._font_name is not None:
create_tag_image(tags, path, layout=self._layout,
size=(width, height),
fontname=self._font_name)
else:
create_tag_image(tags, path, layout=self._layout,
size=(width, height))
return 0
开发者ID:sugarlabs,项目名称:wordcloud,代码行数:33,代码来源:wordcloud.py
示例7: tagCloud
def tagCloud(self):
texts =""
for item in self.docSet:
texts = texts +" " +item
tags = make_tags(get_tag_counts(texts), maxsize=120)
create_tag_image(tags,'filename.png', size=(2000,1000), background=(0, 0, 0, 255), layout=LAYOUT_MIX, fontname='Lobster', rectangular=True)
开发者ID:prathmeshgat,项目名称:SuicidalPersonDetection,代码行数:7,代码来源:TagCloud.py
示例8: _test_large_tag_image
def _test_large_tag_image(self):
start = time.time()
tags = make_tags(get_tag_counts(self.hound.read())[:80], maxsize=120,
colors=COLOR_SCHEMES['audacity'])
create_tag_image(tags, os.path.join(self.test_output, 'cloud_large.png'),
ratio=0.75, background=(0, 0, 0, 255),
layout=LAYOUT_HORIZONTAL, fontname='Lobster')
print "Duration: %d sec" % (time.time() - start)
开发者ID:johnlaudun,项目名称:PyTagCloud,代码行数:8,代码来源:tests.py
示例9: semantic_cloud
def semantic_cloud(topic):
topic_list = TopicList(topic)
tlist = topic_list.GetTopicList()
htagsl = HashtagsList(tlist['statuses'], topic)
hl = htagsl.GetHashtagsList()
cadena = " ".join(hl)
print cadena
tags = make_tags(get_tag_counts(cadena), maxsize=120)
create_tag_image(tags, 'semantic_cloud.png', size=(900, 600), fontname='Lobster')
开发者ID:Pycero91,项目名称:Segundo,代码行数:9,代码来源:ClassPyTw+V3.py
示例10: calAccuracy
def calAccuracy(self):
self.cursor1.execute("select id, name from phone_id;")
result = self.cursor1.fetchall()
for data in result:
print data[0],data[1]
self.phone_id=raw_input("Enter phone id\n");
self.name = raw_input("Enter name:")
import os
os.mkdir('/home/darshan-ubuntu/Project/Products/Features/'+self.name)
self.getReview(1)
tags = make_tags(get_tag_counts(self.actual_review), maxsize=120)
create_tag_image(tags, self.name+'/positive.png', size=(900, 600))
self.actual_review=""
self.getReview(0)
tags = make_tags(get_tag_counts(self.actual_review), maxsize=60)
create_tag_image(tags, self.name+'/negative.png', size=(900, 600))
开发者ID:DarshanMn,项目名称:PhoneReviews,代码行数:18,代码来源:get_words.py
示例11: make_tag_cloud
def make_tag_cloud():
for line in sys.stdin:
try:
text += ' ' + line.strip().lower()
except:
pass
tags = make_tags(get_tag_counts(text), maxsize=150)
create_tag_image(tags, sys.argv[1] + '.png', size=(1024, 768))
开发者ID:gsm1011,项目名称:crawl.twitter,代码行数:9,代码来源:cloud.py
示例12: _test_make_tags
def _test_make_tags(self):
mtags = make_tags(get_tag_counts(self.hound.read())[:60])
found = False
for tag in mtags:
if tag['tag'] == 'sir' and tag['size'] == 40:
found = True
break
self.assertTrue(found)
开发者ID:johnlaudun,项目名称:PyTagCloud,代码行数:9,代码来源:tests.py
示例13: test_layouts
def test_layouts(self):
start = time.time()
tags = make_tags(get_tag_counts(self.hound.read())[:80], maxsize=120)
for layout in LAYOUTS:
create_tag_image(tags, os.path.join(self.test_output, 'cloud_%s.png' % layout),
size=(900, 600),
background=(255, 255, 255, 255),
layout=layout, fontname='Lobster')
print "Duration: %d sec" % (time.time() - start)
开发者ID:mycguo,项目名称:PyTagCloud,代码行数:9,代码来源:tests.py
示例14: make_cloud
def make_cloud(text,fname):
'''create the wordcloud from variable text'''
Data1 = text.lower().replace('http','').replace('rt ','').replace('.co','')
Data = Data1.split()
two_words = [' '.join(ws) for ws in zip(Data, Data[1:])]
wordscount = {w:f for w, f in collections.Counter(two_words).most_common() if f > 200}
sorted_wordscount = sorted(wordscount.iteritems(), key=operator.itemgetter(1),reverse=True)
tags = make_tags(get_tag_counts(Data1)[:50],maxsize=350,minsize=100)
create_tag_image(tags,fname+'.png', size=(3000,3250), background=(0, 0, 0, 255), layout=LAYOUT_MIX, fontname='Lobster', rectangular=True)
开发者ID:Maikflow,项目名称:freelancer_jobs,代码行数:10,代码来源:tagcloud.py
示例15: run
def run(textpath):
text = open(textpath, 'r')
start = time.time()
taglist = get_tag_counts(text.read().decode('utf8'))
cleantaglist = process_tags(taglist)
tags = make_tags(taglist[0:100], colors=COLOR_MAP)
create_tag_image(tags, 'cloud.png', size=(1280, 900), background=(0, 0, 0 , 255), layout=LAYOUT_MOST_HORIZONTAL, crop=False, fontname='Cuprum', fontzoom=2)
tags2 = make_tags(cleantaglist[0:100], colors=COLOR_MAP)
create_tag_image(tags2, 'rcloud.png', size=(1280, 900), background=(0, 0, 0, 255), layout=LAYOUT_MOST_HORIZONTAL, crop=False, fontname='Cuprum', fontzoom=2)
print "Duration: %d sec" % (time.time() - start)
开发者ID:Wild2,项目名称:ruspytagmap,代码行数:10,代码来源:generate.py
示例16: createTagCloud
def createTagCloud(self,rapper):
#creates a tag cloud for the given artist.
#For some reason these imports only work when placed in the function
#but they do not if they are placed at the top of the document
from pytagcloud import create_tag_image, make_tags
from pytagcloud.lang.counter import get_tag_counts
teststr = rapper.rawLyrics
tags = make_tags(get_tag_counts(teststr), maxsize=100)
tags = [a for a in tags if a['size'] > 20]
create_tag_image(tags, 'cloud_large.png', size=(800, 400),
background=(239,101,85,255), fontname='PT Sans Regular')
开发者ID:marcusgreer,项目名称:RapGraph,代码行数:11,代码来源:TP.py
示例17: __init__
def __init__(self, raw_text, except_words):
# Remove words shorter than 2 chars and words in except list
filtered = " ".join([x for x in raw_text.split()
if len(x) > 2 and x not in except_words])
# Get word counts for each word in filtered text
tag_counts = get_tag_counts(filtered)
self.filtered = filtered
self.tags = ptc.make_tags(tag_counts, maxsize=60, minsize=6)
开发者ID:skylergrammer,项目名称:data_science,代码行数:11,代码来源:make_word_cloud.py
示例18: init
def init():
global tags
global test_output
home_folder = os.getenv('USERPROFILE') or os.getenv('HOME')
test_output = os.path.join(home_folder, 'pytagclouds')
if not os.path.exists(test_output):
os.mkdir(test_output )
hound = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../test/pg2852.txt'), 'r')
tags = make_tags(get_tag_counts(hound.read())[:50], maxsize=120, colors=COLOR_SCHEMES['audacity'])
开发者ID:mycguo,项目名称:PyTagCloud,代码行数:12,代码来源:profile.py
示例19: init
def init():
global tags
global test_output
home_folder = os.getenv("USERPROFILE") or os.getenv("HOME")
test_output = os.path.join(home_folder, "pytagclouds")
if not os.path.exists(test_output):
os.mkdir(test_output)
hound = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../test/pg2852.txt"), "r")
tags = make_tags(get_tag_counts(hound.read())[:50], maxsize=120, colors=COLOR_SCHEMES["audacity"])
开发者ID:sjmc7,项目名称:PyTagCloud,代码行数:12,代码来源:profile.py
示例20: openWestCoastCloud
def openWestCoastCloud():
#Stores tags from multiple cities into one text string.
TEXT = getTags(34,118) #Los Angeles
TEXT += ' ' + getTags(37,122) # San Francisco
TEXT += ' ' + getTags(47,122) #Seattle
#Draws Word Cloud
tags = make_tags(get_tag_counts(TEXT), maxsize=80)
#Creates Word Cloud File
create_tag_image(tags, 'cloud_large.png', size=(900, 600), fontname='Lobster')
#Opens Word Cloud File
webbrowser.open('cloud_large.png') # see results
开发者ID:AnitaGarcia819,项目名称:InstaDataViz,代码行数:12,代码来源:WordCloud.py
注:本文中的pytagcloud.lang.counter.get_tag_counts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论