查看“使用python画文字云”的源代码
←
使用python画文字云
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看和复制此页面的源代码。
[[File:cloud_large.png|600px]] 安装包需求: 首先要安装PDFMiner以把一个PDF文件转成txt文件。在[https://pypi.python.org/pypi/pdfminer/ 这里]下载,在[http://www.unixuser.org/~euske/python/pdfminer/index.html#todo 这里]是文件使用说明。 其次要安装[http://www.pygame.org/download.shtml Pygame](windows下要用msi安装包安装,用easy_install有可能出错)。 接着安装simplejson,使用easy_install即可。 最后,easy_install安装[https://pypi.python.org/pypi/pytagcloud pytagcloud]即可。 <syntaxhighlight lang="python"> from pytagcloud import create_tag_image, make_tags from pytagcloud.lang.counter import get_tag_counts from collections import Counter import random f = open("E:\wulingfei\data_science_and_prediction.txt","r").read() s=f.split("\n") tt=[i.strip(" ") for i in s if len(i)>40] text=[] for j in tt: j = j.split(" ") for i in j: if len(i)>5: text.append(i) ct=Counter(text) nct={key:ct[key] for key in ct if ct[key]>4} nt=" ".join([i for i in text if i in nct]) tags = make_tags(get_tag_counts(nt), maxsize=100) create_tag_image(tags, 'E:\wulingfei\cloud_large.png', size=(900, 600), fontname='Lobster') </syntaxhighlight> [[category:python]] [[category:旧词条迁移]]
返回至
使用python画文字云
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
集智百科
集智主页
集智斑图
集智学园
最近更改
所有页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息