专栏名称: 数据分析
专注大数据,移动/互联网,IT科技,电子商务,数据分析/挖掘等领域的综合信息服务与分享平台。合作|约稿请加qq:365242293
目录
相关文章推荐
数局  ·  2025中国大学排名(TOP100) ·  4 天前  
艺恩数据  ·  2025人生四双鞋:京东趋势白皮书 ·  4 天前  
产品可靠性报告  ·  截图确认大数据杀熟!涉及电商、外卖、旅游等平台 ·  2 天前  
产品可靠性报告  ·  截图确认大数据杀熟!涉及电商、外卖、旅游等平台 ·  2 天前  
阿里云大数据AI平台  ·  【5月重点功能发布】阿里云大数据+ AI ... ·  2 天前  
阿里云大数据AI平台  ·  【5月重点功能发布】阿里云大数据+ AI ... ·  2 天前  
51好读  ›  专栏  ›  数据分析

数据挖掘 : 手把手教你做文本挖掘

数据分析  · 公众号  · 大数据  · 2017-02-06 15:40

正文

请到「今天看啥」查看全文


实战

本文所用数据集来自于sougou实验室数据,具体可至如下链接下载:


http://download.labs.sogou.com/dl/sogoulabdown/SogouC.mini.20061102.tar.gz

本文对该数据集做了整合,将各个主题下的新闻汇总到一张csv表格中,数据格式如下图所示:



具体数据可至文章后面的链接。

#加载所需R包
library(tm)
library(Rwordseg)
library(wordcloud)
library(tmcn)
#读取数据
mydata str(mydata)



接下来需要对新闻内容进行分词,在分词之前需要导入一些自定义字典,目的是提高切词的准确性。由于文本中涉及到军事、医疗、财经、体育等方面的内容,故需要将搜狗字典插入到本次分析的字典集中。

#添加自定义字典
installDict(dictpath = 'G:\\dict\\财经金融词汇大全【官方推荐】.scel',
           dictname = 'Caijing', dicttype = 'scel')
installDict(dictpath = 'G:\\dict\\军事词汇大全【官方推荐】.scel',
           dictname = 'Junshi', dicttype = 'scel')
installDict(dictpath = 'G:\\dict\\篮球【官方推荐】.scel',
           dictname = 'Lanqiu', dicttype = 'scel')
installDict(dictpath = 'G:\\dict\\旅游词汇大全【官方推荐】.scel',
           dictname = 'Lvyou', dicttype = 'scel')
installDict(dictpath = 'G:\\dict\\汽车词汇大全【官方推荐】.scel',
           dictname = 'Qiche1', dicttype = 'scel')
installDict(dictpath = 'G:\\dict\\汽车频道专用词库.scel',
           dictname = 'Qiche2', dicttype = 'scel')
installDict(dictpath = 'G:\\dict\\医学词汇大全【官方推荐】.scel',
           dictname = 'Yixue', dicttype = 'scel')
installDict(dictpath = 'G:\\dict\\足球【官方推荐】.scel',
           dictname = 'Zuqiu', dicttype = 'scel')
#查看已安装的词典
listDict()


如果需要卸载某些已导入字典的话,可以使用uninstallDict()函数。


分词前将中文中的英文字母统统去掉。







请到「今天看啥」查看全文