├── ClearText
├── 30wClear.py
├── DealHtml.py
├── EfficRead.py
├── FileRead.py
├── REdealText.py
├── __pycache__
│ └── REdealText.cpython-35.pyc
├── genyield.py
├── htmldome.txt
├── zhline.py
└── zhtools
│ ├── __pycache__
│ ├── langconv.cpython-35.pyc
│ └── zh_wiki.cpython-35.pyc
│ ├── langconv.py
│ └── zh_wiki.py
├── DataVisible
├── 3D.py
├── d3_hookface.png
├── die_visual.svg
├── github.py
├── histogram.py
├── plot.py
├── python_repos.svg
├── scatter.py
├── temper.py
└── weather07.csv
├── ExtractText
├── ConvFormat.py
├── ExtractTxt.py
├── TraverFiles.py
├── __pycache__
│ └── ExtractTxt.cpython-35.pyc
├── pdf2txt.py
└── word2txt.py
├── FeatureVec
├── 30wVec.py
├── StopWords.py
├── TFIDF.py
├── __pycache__
│ ├── StopWords.cpython-35.pyc
│ ├── StopWords.cpython-37.pyc
│ ├── lossval.cpython-35.pyc
│ ├── lossval.cpython-37.pyc
│ ├── wordbag.cpython-35.pyc
│ └── wordbag.cpython-37.pyc
├── lossval.py
├── normdata.py
├── similar.py
├── splitData.py
├── wordbag.py
└── wordset.py
├── GensimVec
├── 30wVec.py
├── HDP.py
├── LDA.py
├── LSA.py
├── LSI.py
├── RP.py
├── StopWords.py
├── TFIDF.py
├── __pycache__
│ ├── StopWords.cpython-35.pyc
│ ├── StopWords.cpython-37.pyc
│ ├── mydict.cpython-35.pyc
│ └── mydict.cpython-37.pyc
├── freqword.py
└── mydict.py
├── PCADim
├── Visual.py
├── __pycache__
│ ├── loadData.cpython-37.pyc
│ ├── loadnews.cpython-37.pyc
│ └── pca.cpython-37.pyc
├── allpca.py
├── analyse.py
├── loadData.py
├── loadnews.py
├── pca.md
├── pca.py
├── pcanews.py
├── secom.data
└── testSet.txt
├── ProcessText
├── 30wDealText.py
├── FeatureWord.py
├── FreqWord.py
├── HLWord.py
├── HanLPCut.py
├── StopWords.py
├── TFIDF.py
├── __pycache__
│ ├── FreqWord.cpython-35.pyc
│ └── StopWords.cpython-35.pyc
└── jiebaCut.py
├── README.md
├── TextClassifier
├── agaricus.py
├── data
│ ├── agaricus.txt.test
│ ├── agaricus.txt.train
│ └── diabetes.csv
└── xgb_model.pkl
└── dataSet
├── CSCMNews下载.txt
├── Corpus
├── EnPapers
│ ├── 历史
│ │ ├── 1.pdf
│ │ ├── 10.pdf
│ │ ├── 11.pdf
│ │ ├── 12.pdf
│ │ ├── 13.pdf
│ │ ├── 14.pdf
│ │ ├── 15.pdf
│ │ ├── 16.pdf
│ │ ├── 17.pdf
│ │ ├── 18.pdf
│ │ ├── 19.pdf
│ │ ├── 2.pdf
│ │ ├── 20.pdf
│ │ ├── 21.pdf
│ │ ├── 22.pdf
│ │ ├── 23.pdf
│ │ ├── 24.pdf
│ │ ├── 25.pdf
│ │ ├── 26.pdf
│ │ ├── 27.pdf
│ │ ├── 28.pdf
│ │ ├── 29.pdf
│ │ ├── 3.pdf
│ │ ├── 30.pdf
│ │ ├── 4.pdf
│ │ ├── 5.pdf
│ │ ├── 6.pdf
│ │ ├── 7.pdf
│ │ ├── 8.pdf
│ │ └── 9.pdf
│ ├── 教育
│ │ ├── 1.pdf
│ │ ├── 10.pdf
│ │ ├── 11.pdf
│ │ ├── 12.pdf
│ │ ├── 13.pdf
│ │ ├── 14.pdf
│ │ ├── 15.pdf
│ │ ├── 16.pdf
│ │ ├── 17.pdf
│ │ ├── 18.pdf
│ │ ├── 19.pdf
│ │ ├── 2.pdf
│ │ ├── 20.pdf
│ │ ├── 21.pdf
│ │ ├── 22.pdf
│ │ ├── 23.pdf
│ │ ├── 24.pdf
│ │ ├── 25.pdf
│ │ ├── 26.pdf
│ │ ├── 27.pdf
│ │ ├── 28.pdf
│ │ ├── 29.pdf
│ │ ├── 3.pdf
│ │ ├── 30.pdf
│ │ ├── 4.pdf
│ │ ├── 5.pdf
│ │ ├── 6.pdf
│ │ ├── 7.pdf
│ │ ├── 8.pdf
│ │ └── 9.pdf
│ └── 汽车
│ │ ├── 1.pdf
│ │ ├── 10.pdf
│ │ ├── 11.pdf
│ │ ├── 12.pdf
│ │ ├── 13.pdf
│ │ ├── 14.pdf
│ │ ├── 15.pdf
│ │ ├── 16.pdf
│ │ ├── 17.pdf
│ │ ├── 18.pdf
│ │ ├── 19.pdf
│ │ ├── 2.pdf
│ │ ├── 20.pdf
│ │ ├── 21.pdf
│ │ ├── 22.pdf
│ │ ├── 23.pdf
│ │ ├── 24.pdf
│ │ ├── 25.pdf
│ │ ├── 26.pdf
│ │ ├── 27.pdf
│ │ ├── 28.pdf
│ │ ├── 29.pdf
│ │ ├── 3.pdf
│ │ ├── 30.pdf
│ │ ├── 4.pdf
│ │ ├── 5.pdf
│ │ ├── 6.pdf
│ │ ├── 7.pdf
│ │ ├── 8.pdf
│ │ └── 9.pdf
├── pdftotxt
│ └── 2018年世界新闻自由日.pdf
└── wordtotxt
│ └── 科技项目数据挖掘决策架构.docx
├── StopWord
├── EN_stopwords.txt
├── NLPIR_stopwords.txt
├── user_dict.txt
└── 词性.txt
└── files
├── dataset.data
├── dataset.txt
├── mycorpus.dict
├── mycorpus.txt
├── newsdata.txt
└── secom.data
/ClearText/30wClear.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 |
3 | """
4 | Description: 6万条新闻文本数据清洗
5 | Prompt: code in Python3 env
6 | """
7 |
8 | import os,re,time
9 | from REdealText import textParse
10 | #******************** 高效读取文件***********************************
11 |
12 |
13 | class loadFolders(object): # 迭代器
14 | def __init__(self, par_path):
15 | self.par_path = par_path
16 | def __iter__(self):
17 | for file in os.listdir(self.par_path):
18 | file_abspath = os.path.join(self.par_path, file)
19 | if os.path.isdir(file_abspath): # if file is a folder
20 | yield file_abspath
21 |
22 | class loadFiles(object):
23 | def __init__(self, par_path):
24 | self.par_path = par_path
25 | def __iter__(self):
26 | folders = loadFolders(self.par_path)
27 | for folder in folders: # level directory
28 | catg = folder.split(os.sep)[-1]
29 | for file in os.listdir(folder): # secondary directory
30 | file_path = os.path.join(folder, file)
31 | if os.path.isfile(file_path):
32 | this_file = open(file_path, 'rb') #rb读取方式更快
33 | content = this_file.read().decode('utf8')
34 | yield catg, content
35 | this_file.close()
36 |
37 |
38 | # 正则对字符串清洗
39 | def textParse(str_doc):
40 | # 正则过滤掉特殊符号、标点、英文、数字等。
41 | r1 = '[a-zA-Z0-9’!"#$%&\'()*+,-./::;;|<=>?@,—。?★、…【】《》?“”‘’![\\]^_`{|}~]+'
42 | # 去除空格
43 | r2 = '\s+'
44 | # 去除换行符
45 | str_doc=re.sub(r1, ' ', str_doc)
46 | # 多个空格成1个
47 | str_doc=re.sub(r2, ' ', str_doc)
48 | # 去除换行符
49 | # str_doc = str_doc.replace('\n',' ')
50 | return str_doc
51 |
52 |
53 | if __name__=='__main__':
54 | start = time.time()
55 |
56 | filepath = os.path.abspath(r'../dataSet/CSCMNews6w')
57 | files = loadFiles(filepath)
58 | n = 2 # n 表示抽样率, n抽1
59 | for i, msg in enumerate(files):
60 | if i % n == 0:
61 | catg = msg[0]
62 | file = msg[1]
63 | file = textParse(file)
64 | if int(i/n) % 1000 == 0:
65 | print('{t} *** {i} \t docs has been dealed'
66 | .format(i=i, t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())),'\n',catg,':\t',file[:20])
67 |
68 | end = time.time()
69 | print('total spent times:%.2f' % (end-start)+ ' s')
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/ClearText/DealHtml.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 | import re
3 |
4 | """
5 | Description: 处理文本的HTML标签、特殊符号
6 | Prompt: code in Python3 env
7 | """
8 |
9 |
10 | # 清洗HTML标签文本
11 | # @param htmlstr HTML字符串.
12 | def filter_tags(htmlstr):
13 | # 过滤DOCTYPE
14 | htmlstr = ' '.join(htmlstr.split()) # 去掉多余的空格
15 | re_doctype = re.compile(r' ', re.S)
16 | s = re_doctype.sub('',htmlstr)
17 |
18 | # 过滤CDATA
19 | re_cdata = re.compile('//]∗ //\] > ', re.I)
20 | s = re_cdata.sub('', s)
21 |
22 | # Script
23 | re_script = re.compile('<\s*script[^>]*>[^<]*<\s*/\s*script\s*>', re.I)
24 | s = re_script.sub('', s) # 去掉SCRIPT
25 |
26 | # style
27 | re_style = re.compile('<\s*style[^>]*>[^<]*<\s*/\s*style\s*>', re.I)
28 | s = re_style.sub('', s) # 去掉style
29 |
30 | # 处理换行
31 | re_br = re.compile('
')
32 | s = re_br.sub('', s) # 将br转换为换行
33 |
34 | # HTML标签
35 | re_h = re.compile('?\w+[^>]*>')
36 | s = re_h.sub('', s) # 去掉HTML 标签
37 |
38 | # HTML注释
39 | re_comment = re.compile('')
40 | s = re_comment.sub('', s)
41 |
42 | # 多余的空行
43 | blank_line = re.compile('\n+')
44 | s = blank_line.sub('', s)
45 |
46 | blank_line_l = re.compile('\n')
47 | s = blank_line_l.sub('', s)
48 |
49 | blank_kon = re.compile('\t')
50 | s = blank_kon.sub('', s)
51 |
52 | blank_one = re.compile('\r\n')
53 | s = blank_one.sub('', s)
54 |
55 | blank_two = re.compile('\r')
56 | s = blank_two.sub('', s)
57 |
58 | blank_three = re.compile(' ')
59 | s = blank_three.sub('', s)
60 |
61 | # 剔除超链接
62 | http_link = re.compile(r'(http://.+.html)')
63 | s = http_link.sub('', s)
64 | return s
65 |
66 |
67 |
68 | def readTxt(path):
69 | res = ''
70 | with open(path,'r',encoding='utf-8') as f:
71 | res = f.read()
72 | return res
73 |
74 |
75 | if __name__=='__main__':
76 | str_doc = readTxt(r'./htmldome.txt')
77 | s=filter_tags(str_doc)
78 | print(s)
79 |
--------------------------------------------------------------------------------
/ClearText/EfficRead.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 |
3 | """
4 | Description: 在文本预处理中,实现高效的读取文本文件
5 | Prompt: code in Python3 env
6 | """
7 |
8 | import os,time
9 |
10 |
11 | class loadFolders(object): # 迭代器
12 | def __init__(self, par_path):
13 | self.par_path = par_path
14 | def __iter__(self):
15 | for file in os.listdir(self.par_path):
16 | file_abspath = os.path.join(self.par_path, file)
17 | if os.path.isdir(file_abspath): # if file is a folder
18 | yield file_abspath
19 |
20 | class loadFiles(object):
21 | def __init__(self, par_path):
22 | self.par_path = par_path
23 | def __iter__(self):
24 | folders = loadFolders(self.par_path)
25 | for folder in folders: # level directory
26 | catg = folder.split(os.sep)[-1]
27 | for file in os.listdir(folder): # secondary directory
28 | yield catg, file
29 |
30 |
31 |
32 | if __name__=='__main__':
33 | start = time.time()
34 |
35 | # filepath = os.path.abspath(r'../dataSet/Corpus/new_EnPapers')
36 | filepath = os.path.abspath(r'../dataSet/CSCMNews')
37 | files = loadFiles(filepath)
38 | for i, msg in enumerate(files):
39 | if i%5000 == 0:
40 | print('{t} *** {i} \t docs has been Read'.format(i=i, t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())))
41 |
42 | end = time.time()
43 | print('total spent times:%.2f' % (end-start)+ ' s')
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/ClearText/FileRead.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 |
3 | """
4 | Description: 批量文档格式自动转化txt
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import os,time
10 |
11 | '''
12 | 功能描述:遍历目录,对子文件单独处理
13 | '''
14 | # 2 遍历目录文件
15 | def TraversalDir(rootDir):
16 | # 返回指定目录包含的文件或文件夹的名字的列表
17 | for i,lists in enumerate(os.listdir(rootDir)):
18 | # 待处理文件夹名字集合
19 | path = os.path.join(rootDir, lists)
20 | # 核心算法,对文件具体操作
21 | if os.path.isfile(path):
22 | if i%5000 == 0:
23 | print('{t} *** {i} \t docs has been read'.format(i=i, t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())))
24 | # 递归遍历文件目录
25 | if os.path.isdir(path):
26 | TraversalDir(path)
27 |
28 |
29 |
30 | if __name__ == '__main__':
31 | t1=time.time()
32 |
33 | # 根目录文件路径
34 | # rootDir = os.path.abspath(r'../dataSet/Corpus/new_EnPapers')
35 | rootDir = r"../dataSet/CSCMNews"
36 | TraversalDir(rootDir)
37 |
38 | t2=time.time()
39 | print('totally cost %.2f' % (t2-t1)+' s')
--------------------------------------------------------------------------------
/ClearText/REdealText.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | import re,itertools
4 |
5 | """
6 | Description: 正则清洗数据
7 | Prompt: code in Python3 env
8 | """
9 |
10 | '''
11 | re.I 使匹配对大小写不敏感
12 | re.L 做本地化识别(locale-aware)匹配
13 | re.M 多行匹配,影响 ^ 和 $
14 | re.S 使 . 匹配包括换行在内的所有字符
15 | re.U 根据Unicode字符集解析字符。这个标志影响 \w, \W, \b, \B.
16 | re.X 该标志通过给予你更灵活的格式以便你将正则表达式写得更易于理解。
17 | '''
18 | # 正则对字符串清洗
19 | def textParse(str_doc):
20 | # 正则过滤掉特殊符号、标点、英文、数字等。
21 | r1 = '[a-zA-Z0-9’!"#$%&\'()*+,-./::;;|<=>?@,—。?★、…【】《》?“”‘’![\\]^_`{|}~]+'
22 | # 去除空格
23 | r2 = '\s+'
24 | # 去除换行符
25 | str_doc=re.sub(r1, ' ', str_doc)
26 | # 多个空格成1个
27 | str_doc=re.sub(r2, ' ', str_doc)
28 | # 去除换行符
29 | # str_doc = str_doc.replace('\n',' ')
30 | return str_doc
31 |
32 |
33 | # 读取文本信息
34 | def readFile(path):
35 | str_doc = ""
36 | with open(path,'r',encoding='utf-8') as f:
37 | str_doc = f.read()
38 | return str_doc
39 |
40 |
41 |
42 | if __name__=='__main__':
43 | # 1 读取文本
44 | path= r'../dataSet/CSCMNews/体育/0.txt'
45 | str_doc = readFile(path)
46 | # print(str_doc)
47 |
48 | # 2 正则清洗字符串
49 | word_list=textParse(str_doc)
50 | print(word_list)
51 |
52 |
--------------------------------------------------------------------------------
/ClearText/__pycache__/REdealText.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/ClearText/__pycache__/REdealText.cpython-35.pyc
--------------------------------------------------------------------------------
/ClearText/genyield.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 |
3 | """
4 | Description: yield生成器
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import random,os,time
10 |
11 |
12 | '''
13 | 斐波那契数列: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144......
14 | 这个数列从第3项开始,每一项都等于前两项之和
15 | 数学上定义:F(0)=1,F(1)=1, F(n)=F(n-1)+F(n-2)(n>=2,n∈N*)
16 | '''
17 | # 普通斐波那契数列
18 | def fab1(max):
19 | n, a, b = 0, 0, 1
20 | while n < max:
21 | # if n<20:
22 | # print('->',b)
23 | a, b = b, a + b
24 | n = n + 1
25 |
26 |
27 | # 生成器:斐波那契数列
28 | def fab2(max):
29 | n, a, b = 0, 0, 1
30 | while n < max:
31 | yield b # 使用 yield
32 | a, b = b, a + b
33 | n = n + 1
34 |
35 |
36 | # 生成器案例。 Generator / yield
37 | def GeneratorDome():
38 | maxnum = 1000 # 最大迭代次数
39 | # 普通斐波那契数列耗时
40 | t1 = time.time()
41 | # fab1(maxnum)
42 | t2 = time.time()
43 | print('fab1 total tims %.2f ' % (1000*(t2-t1)) + ' ms')
44 |
45 | # 生成器方法耗时
46 | b = fab2(maxnum)
47 | t3 = time.time()
48 | print('fab2 total tims %.2f ' % (1000*(t3-t2)) + ' ms')
49 |
50 |
51 |
52 | if __name__=='__main__':
53 | GeneratorDome()
54 |
55 |
56 | # 1:数组、链表、字符串、文件等缺点就是所有数据都在内存里,海量的数据耗内存。
57 | # 2:生成器是可以迭代的,工作原理就是重复调用next()方法,直到捕获一个异常。
58 | # 3:有yield的函数不再是一个普通的函数,而是一个生成器generator,可用于迭代。
59 | # 4:yield是一个类似return 的关键字
--------------------------------------------------------------------------------
/ClearText/htmldome.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 上港5-4恒大5分领跑剑指冠军,下轮打平便可夺冠,武磊平纪录 — 广州恒大淘宝|上海上港|蔡慧康|武磊|胡尔克|张成林|阿兰|保利尼奥|王燊超|吕文君|懂球帝
10 |
11 |
12 |
13 | 事件频率的直方图00202040406060808010010012012014014016016012345615266.2923076923077279.38891276321441171173.2153846153846254.48560378169322175280.13846153846157249.24280189084663168387.0615384615385258.41770519982814150493.9846153846154282.010313708637745179600.9076923076923244.000000000000036事件频率的直方图事件的结果事件的频率事件
--------------------------------------------------------------------------------
/DataVisible/github.py:
--------------------------------------------------------------------------------
1 | import matplotlib,requests,pygal
2 |
3 | #加入中文显示
4 | import matplotlib.font_manager as fm
5 | # 解决中文乱码,本案例使用宋体字
6 | myfont=fm.FontProperties(fname=r"C:\\Windows\\Fonts\\simsun.ttc")
7 |
8 |
9 |
10 | def repos_hist():
11 | #查看API速率限制
12 | url = 'https://api.github.com/search/repositories?q=language:python&sort=stars'
13 | r = requests.get(url)
14 | print("Status code:",r.status_code) # 状态码200表示成功
15 | response_dict = r.json() # 将API响应存储在一个变量里面
16 | print("Hithub总的Python仓库数:",response_dict['total_count'])
17 |
18 | # 探索有关仓库的信息
19 | repo_dicts = response_dict['items']
20 | names,stars = [],[]
21 | for repo_dict in repo_dicts:
22 | names.append(repo_dict['name'])
23 | stars.append(repo_dict['stargazers_count'])
24 | # 可视化,x_label_rotation围绕x轴旋转45度,show_legend图例隐藏与否
25 | my_config = pygal.Config()
26 | chart = pygal.Bar(my_config)
27 | chart.title = 'Github最受欢迎的星标项目'
28 | chart.x_labels = names
29 | chart.add('星标',stars)
30 |
31 | chart.render_to_file('python_repos.svg')
32 |
33 | # print('查看每个python仓库的信息:\n')
34 | # for repo_dict in repo_dicts:
35 | # print('项目名称:',repo_dict['name'])
36 | # print('所有者:',repo_dict['owner']['login'])
37 | # print('星级评分:',repo_dict['stargazers_count'])
38 | # print('项目URL:',repo_dict['html_url'])
39 | # print('仓库描述:',repo_dict['description'])
40 | # print('\n')
41 |
42 |
43 |
44 | if __name__ == '__main__':
45 | repos_hist()
--------------------------------------------------------------------------------
/DataVisible/histogram.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:matplotlib绘制直方图
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | '''
10 | 直方图定义:
11 | 直方图(英语:Histogram)是一种对数据分布情况的图形表示,是一种二维统计图表,它的两个坐标分别是统计样本和该样本对应的某个属性的度量。
12 |
13 | 优点:
14 | 可以很清晰地看出每个类的总和及各个属性的比例。
15 | 缺点:
16 | 不容易看出各个属性的频数。
17 |
18 | 应用场景
19 | 适合的场景:
20 | 适合应用到分类数据对比。比如一个游戏销量的图表,展示不同游戏类型的销量对比。 不适合的场景:
21 | 1 分类太多不适合使用纵向柱状图,如对比不同省份的人口数量。
22 | 2 不适合表示趋势。柱状图使用矩形的长度(宽度)来对比分类数据的大小,非常方便 临近的数据进行大小的对比,不适合展示连续数据的趋势。
23 |
24 | '''
25 |
26 |
27 | import matplotlib
28 | import matplotlib.pyplot as plt
29 | import pygal # Pygal生成可缩略的矢量图文件
30 |
31 | #加入中文显示
32 | import matplotlib.font_manager as fm
33 | # 解决中文乱码,本案例使用宋体字
34 | myfont=fm.FontProperties(fname=r"C:\\Windows\\Fonts\\simsun.ttc")
35 |
36 |
37 | def histogram(xvalues,yvalues):
38 | # 绘制直方图
39 | hist = pygal.Bar()
40 |
41 | # 设置散点图标题和横纵坐标标题
42 | hist.title = '事件频率的直方图'
43 | hist.x_title = '事件的结果'
44 | hist.y_title = '事件的频率'
45 |
46 | # 绘制气温图,设置图形大小
47 | fig = plt.figure(dpi=100,figsize=(10,6))
48 |
49 | # 事件的结果
50 | hist.x_labels = xvalues
51 |
52 | # 事件的统计频率
53 | hist.add('事件',yvalues)
54 |
55 | # 保存文件路径
56 | hist.render_to_file('die_visual.svg')
57 |
58 | if __name__ == '__main__':
59 | xvalues = list(range(1,100)) #校正坐标点,即横坐标值列表
60 | yvalues = [x**2 for x in xvalues] # 纵坐标值列表
61 |
62 | x_result = [1,2,3,4,5,6]
63 | y_frequencies = [152,171,175,168,150,179]
64 |
65 | histogram(x_result,y_frequencies)
66 |
--------------------------------------------------------------------------------
/DataVisible/plot.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:matplotlib绘制折线图
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 |
10 |
11 | '''
12 | 折线图定义:
13 | 折线图用于显示数据在一个连续的时间间隔或者时间跨度上的变化,它的特点是反映 事物随时间或有序类别而变化的趋势。在折线图中,数据是递增还是递减、增减的速率、增 减的规律(周期性、螺旋性等)、峰值等特征都可以清晰地反映出来。所以,折线图常用来 分析数据随时间变化的趋势,也可用来分析多组数据随时间变化的相互作用和相互影响。
14 |
15 | 折线图应用场景:
16 | 适用场景:
17 | 1 有序的因变量,比如时间。某监控系统的折线图表,显示了请求次数和响应时间随时 间的变化趋势。
18 | 2 不同月份的温度。
19 | 不适合的场景:
20 | 1 当水平轴的数据类型为无序的分类或者垂直轴的数据类型为连续时间时,不适合使用 折线图。
21 | 2 当折线的条数过多时不建议将多条线绘制在一张图上。
22 |
23 | '''
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | import matplotlib
33 | import matplotlib.pyplot as plt
34 | #加入中文显示
35 | import matplotlib.font_manager as fm
36 |
37 | # 解决中文乱码,本案例使用宋体字
38 | myfont=fm.FontProperties(fname=r"C:\\Windows\\Fonts\\simsun.ttc")
39 |
40 | def line_chart(xvalues,yvalues):
41 | # 绘制折线图,c颜色设置,alpha透明度
42 | plt.plot(xvalues,yvalues,linewidth=5,alpha=0.5,c='red') # num_squares数据值,linewidth设置线条粗细
43 |
44 | # 设置折线图标题和横纵坐标标题
45 | plt.title("Python绘制折线图",fontsize=20,fontname='宋体',fontproperties=myfont)
46 | plt.xlabel('横坐标',fontsize=15,fontname='宋体',fontproperties=myfont)
47 | plt.ylabel('纵坐标',fontsize=15,fontname='宋体',fontproperties=myfont)
48 |
49 | # 设置刻度标记大小,axis='both'参数影响横纵坐标,labelsize刻度大小
50 | plt.tick_params(axis='both',labelsize=10)
51 |
52 | # 显示图形
53 | plt.show()
54 |
55 |
56 |
57 | if __name__ == '__main__':
58 | # xvalues = list(range(1,100)) #校正坐标点,即横坐标值列表
59 | # yvalues = [x**2 for x in xvalues] # 纵坐标值列表
60 |
61 | x_result = [1,2,3,4,5,6]
62 | y_frequencies = [152,171,175,168,150,179]
63 |
64 | line_chart(x_result,y_frequencies)
65 |
--------------------------------------------------------------------------------
/DataVisible/scatter.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:matplotlib绘制散点图
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 |
10 | '''
11 | 散点图定义:
12 | 散点图也叫 X-Y 图,它将所有的数据以点的形式展现在直角坐标系上,以显示变量之 间的相互影响程度,点的位置由变量的数值决定。
13 | 通过观察散点图上数据点的分布情况,我们可以推断出变量间的相关性。如果变量之间 不存在相互关系,那么在散点图上就会表现为随机分布的离散的点,如果存在某种相关性, 那么大部分的数据点就会相对密集并以某种趋势呈现。数据的相关关系主要分为:正相关 (两个变量值同时增长)、负相关(一个变量值增加另一个变量值下降)、不相关、线性相关、 指数相关等。那些离点集群较远的点称为离群点或者异常点。
14 | 散点图经常与回归线(就是最准确地贯穿所有点的线)结合使用,归纳分析现有数据以 进行预测分析。
15 |
16 | 散点图的特点:
17 | 散点图通常用于显示和比较数值。不仅可以显示趋势,还能显示数据集群的形状,以及 在数据云团中各数据点的关系。
18 |
19 | 散点图应用场景:
20 | 男女身高和体重的例子来展示上述所描述的散点图的功能。
21 |
22 | '''
23 |
24 |
25 | import matplotlib
26 | import matplotlib.pyplot as plt
27 |
28 | #加入中文显示
29 | import matplotlib.font_manager as fm
30 | # 解决中文乱码,本案例使用宋体字
31 | myfont=fm.FontProperties(fname=r"C:\\Windows\\Fonts\\simsun.ttc")
32 |
33 |
34 | def scatter_chart(xvalues,yvalues):
35 | # 绘制散点图,s设置点的大小,c数据点的颜色,edgecolors数据点的轮廓
36 | plt.scatter(xvalues,yvalues,c='green',edgecolors='none',s=20)
37 |
38 | # 设置散点图标题和横纵坐标标题
39 | plt.title("Python绘制折线图",fontsize=30,fontname='宋体',fontproperties=myfont)
40 | plt.xlabel('横坐标',fontsize=20,fontname='宋体',fontproperties=myfont)
41 | plt.ylabel('纵坐标',fontsize=20,fontname='宋体',fontproperties=myfont)
42 |
43 | # 设置刻度标记大小,axis='both'参数影响横纵坐标,labelsize刻度大小
44 | plt.tick_params(axis='both',which='major',labelsize=10)
45 |
46 | # 设置每个坐标轴取值范围
47 | plt.axis([80,100,6400,10000])
48 |
49 | # 显示图形
50 | plt.show()
51 |
52 | # 自动保存图表,bbox_inches剪除图片空白区
53 | # plt.savefig('squares_plot.png',bbox_inches='tight')
54 |
55 |
56 | if __name__ == '__main__':
57 | xvalues = list(range(1,100)) #校正坐标点,即横坐标值列表
58 | yvalues = [x**2 for x in xvalues] # 纵坐标值列表
59 |
60 | x_result = [1,2,3,4,5,6]
61 | y_frequencies = [152,171,175,168,150,179]
62 |
63 | scatter_chart(xvalues,yvalues)
64 |
--------------------------------------------------------------------------------
/DataVisible/temper.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:matplotlib绘制复杂图
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import matplotlib
10 | import matplotlib.pyplot as plt
11 | import csv
12 | from datetime import datetime
13 | #加入中文显示
14 | import matplotlib.font_manager as fm
15 | # 解决中文乱码,本案例使用宋体字
16 | myfont=fm.FontProperties(fname=r"C:\\Windows\\Fonts\\simsun.ttc")
17 |
18 |
19 |
20 | def temper_char():
21 | fig = plt.figure() # 将画布划分为1行1列1块
22 | dates,highs,lows = [],[],[]
23 | with open(r'./weather07.csv') as f:
24 | reader = csv.reader(f)
25 | header_row = next(reader) # 返回文件第一行
26 | for row in reader:
27 | current_date = datetime.strptime(row[0],"%Y-%m-%d")
28 | dates.append(current_date)
29 | highs.append(int(row[1]))
30 | lows.append((int(row[3])))
31 |
32 |
33 | # 接收数据并绘制图形,facecolor填充区域颜色
34 | plt.plot(dates,highs,c='red',linewidth=2,alpha=0.5)
35 | plt.plot(dates,lows,c='green',linewidth=2,alpha=0.5)
36 | plt.fill_between(dates,highs,lows,facecolor='blue',alpha=0.2)
37 |
38 | # 设置散点图标题和横纵坐标标题
39 | plt.title("日常最高气温,2018年7月",fontsize=10,fontname='宋体',fontproperties=myfont)
40 | plt.xlabel('横坐标',fontsize=10,fontname='宋体',fontproperties=myfont)
41 | plt.ylabel('温度',fontsize=10,fontname='宋体',fontproperties=myfont)
42 |
43 | # 绘制斜的日期
44 | fig.autofmt_xdate()
45 |
46 | # 设置刻度标记大小,axis='both'参数影响横纵坐标,labelsize刻度大小
47 | plt.tick_params(axis='both',which='major',labelsize=8)
48 |
49 | # 显示图形
50 | plt.show()
51 |
52 |
53 |
54 | if __name__ == '__main__':
55 | xvalues = list(range(1,100)) #校正坐标点,即横坐标值列表
56 | yvalues = [x**2 for x in xvalues] # 纵坐标值列表
57 |
58 | x_result = [1,2,3,4,5,6]
59 | y_frequencies = [152,171,175,168,150,179]
60 |
61 | temper_char()
62 |
--------------------------------------------------------------------------------
/DataVisible/weather07.csv:
--------------------------------------------------------------------------------
1 | AKDT,Max TemperatureF,Mean TemperatureF,Min TemperatureF,Max Dew PointF,MeanDew PointF,Min DewpointF,Max Humidity, Mean Humidity, Min Humidity, Max Sea Level PressureIn, Mean Sea Level PressureIn, Min Sea Level PressureIn, Max VisibilityMiles, Mean VisibilityMiles, Min VisibilityMiles, Max Wind SpeedMPH, Mean Wind SpeedMPH, Max Gust SpeedMPH,PrecipitationIn, CloudCover, Events, WindDirDegrees
2 | 2014-7-1,64,56,50,53,51,48,96,83,58,30.19,30.00,29.79,10,10,10,7,4,,0.00,7,,337
3 | 2014-7-2,71,62,55,55,52,46,96,80,51,29.81,29.75,29.66,10,9,2,13,5,,0.14,7,Rain,327
4 | 2014-7-3,64,58,53,55,53,51,97,85,72,29.88,29.86,29.81,10,10,8,15,4,,0.01,6,,258
5 | 2014-7-4,59,56,52,52,51,50,96,88,75,29.91,29.89,29.87,10,9,2,9,2,,0.07,7,Rain,255
6 | 2014-7-5,69,59,50,52,50,46,96,72,49,29.88,29.82,29.79,10,10,10,13,5,,0.00,6,,110
7 | 2014-7-6,62,58,55,51,50,46,80,71,58,30.13,30.07,29.89,10,10,10,20,10,29,0.00,6,Rain,213
8 | 2014-7-7,61,57,55,56,53,51,96,87,75,30.10,30.07,30.05,10,9,4,16,4,25,0.14,8,Rain,211
9 | 2014-7-8,55,54,53,54,53,51,100,94,86,30.10,30.06,30.04,10,6,2,12,5,23,0.84,8,Rain,159
10 | 2014-7-9,57,55,53,56,54,52,100,96,83,30.24,30.18,30.11,10,7,2,9,5,,0.13,8,Rain,201
11 | 2014-7-10,61,56,53,53,52,51,100,90,75,30.23,30.17,30.03,10,8,2,8,3,,0.03,8,Rain,215
12 | 2014-7-11,57,56,54,56,54,51,100,94,84,30.02,30.00,29.98,10,5,2,12,5,,1.28,8,Rain,250
13 | 2014-7-12,59,56,55,58,56,55,100,97,93,30.18,30.06,29.99,10,6,2,15,7,26,0.32,8,Rain,275
14 | 2014-7-13,57,56,55,58,56,55,100,98,94,30.25,30.22,30.18,10,5,1,8,4,,0.29,8,Rain,291
15 | 2014-7-14,61,58,55,58,56,51,100,94,83,30.24,30.23,30.22,10,7,0,16,4,,0.01,8,Fog,307
16 | 2014-7-15,64,58,55,53,51,48,93,78,64,30.27,30.25,30.24,10,10,10,17,12,,0.00,6,,318
17 | 2014-7-16,61,56,52,51,49,47,89,76,64,30.27,30.23,30.16,10,10,10,15,6,,0.00,6,,294
18 | 2014-7-17,59,55,51,52,50,48,93,84,75,30.16,30.04,29.82,10,10,6,9,3,,0.11,7,Rain,232
19 | 2014-7-18,63,56,51,54,52,50,100,84,67,29.79,29.69,29.65,10,10,7,10,5,,0.05,6,Rain,299
20 | 2014-7-19,60,57,54,55,53,51,97,88,75,29.91,29.82,29.68,10,9,2,9,2,,0.00,8,,292
21 | 2014-7-20,57,55,52,54,52,50,94,89,77,29.92,29.87,29.78,10,8,2,13,4,,0.31,8,Rain,155
22 | 2014-7-21,69,60,52,53,51,50,97,77,52,29.99,29.88,29.78,10,10,10,13,4,,0.00,5,,297
23 | 2014-7-22,63,59,55,56,54,52,90,84,77,30.11,30.04,29.99,10,10,10,9,3,,0.00,6,Rain,240
24 | 2014-7-23,62,58,55,54,52,50,87,80,72,30.10,30.03,29.96,10,10,10,8,3,,0.00,7,,230
25 | 2014-7-24,59,57,54,54,52,51,94,84,78,29.95,29.91,29.89,10,9,3,17,4,28,0.06,8,Rain,207
26 | 2014-7-25,57,55,53,55,53,51,100,92,81,29.91,29.87,29.83,10,8,2,13,3,,0.53,8,Rain,141
27 | 2014-7-26,57,55,53,57,55,54,100,96,93,29.96,29.91,29.87,10,8,1,15,5,24,0.57,8,Rain,216
28 | 2014-7-27,61,58,55,55,54,53,100,92,78,30.10,30.05,29.97,10,9,2,13,5,,0.30,8,Rain,213
29 | 2014-7-28,59,56,53,57,54,51,97,94,90,30.06,30.00,29.96,10,8,2,9,3,,0.61,8,Rain,261
30 | 2014-7-29,61,56,51,54,52,49,96,89,75,30.13,30.02,29.95,10,9,3,14,4,,0.25,6,Rain,153
31 | 2014-7-30,61,57,54,55,53,52,97,88,78,30.31,30.23,30.14,10,10,8,8,4,,0.08,7,Rain,160
32 | 2014-7-31,66,58,50,55,52,49,100,86,65,30.31,30.29,30.26,10,9,3,10,4,,0.00,3,,217
33 |
--------------------------------------------------------------------------------
/ExtractText/ConvFormat.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 |
3 | """
4 | Description: 批量文档格式自动转化txt
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import ExtractTxt as ET
10 | import os,time
11 |
12 |
13 | '''
14 | 功能描述:遍历目录,对子文件单独处理
15 | 参数描述:1 rootDir 根目录 2 deffun:方法参数 3 saveDir: 保存路径
16 | '''
17 | class TraversalFun():
18 | # 1 初始化
19 | def __init__(self,rootDir,func=None,saveDir=""):
20 | self.rootDir = rootDir # 目录路径
21 | self.func = func # 参数方法
22 | self.saveDir = saveDir # 保存路径
23 |
24 | # 2 遍历目录文件
25 | def TraversalDir(self):
26 | # 切分文件上级目录和文件名
27 | dirs,latername = os.path.split(self.rootDir)
28 | # print(rootDir,'\n',dirs,'\n',latername)
29 |
30 | # 保存目录
31 | save_dir = ""
32 | if self.saveDir=="": # 默认文件保存路径
33 | save_dir = os.path.abspath(os.path.join(dirs,'new_'+latername))
34 | else: save_dir = self.saveDir
35 |
36 | # 创建目录文件
37 | if not os.path.exists(save_dir): os.makedirs(save_dir)
38 | print("保存目录:\n"+save_dir)
39 |
40 | # 遍历文件并将其转化txt文件
41 | TraversalFun.AllFiles(self,self.rootDir,save_dir)
42 |
43 |
44 | # 3 递归遍历所有文件,并提供具体文件操作功能
45 | def AllFiles(self,rootDir,save_dir=''):
46 | # 返回指定目录包含的文件或文件夹的名字的列表
47 | for lists in os.listdir(rootDir):
48 | # 待处理文件夹名字集合
49 | path = os.path.join(rootDir, lists)
50 |
51 | # 核心算法,对文件具体操作
52 | if os.path.isfile(path):
53 | self.func(os.path.abspath(path),os.path.abspath(save_dir))
54 |
55 | # 递归遍历文件目录
56 | if os.path.isdir(path):
57 | newpath = os.path.join(save_dir, lists)
58 | if not os.path.exists(newpath):
59 | os.mkdir(newpath)
60 | TraversalFun.AllFiles(self,path,newpath)
61 |
62 |
63 |
64 |
65 | if __name__ == '__main__':
66 | time_start=time.time()
67 |
68 | # 根目录文件路径
69 | rootDir = r"../dataSet/Corpus/EnPapers"
70 | # saveDir = r"./Corpus/TxtEnPapers"
71 | tra=TraversalFun(rootDir,ET.Files2Txt) # 默认方法参数打印所有文件路径
72 | tra.TraversalDir() # 遍历文件并进行相关操作
73 |
74 | time_end=time.time()
75 | print('totally cost',time_end-time_start,'s')
--------------------------------------------------------------------------------
/ExtractText/ExtractTxt.py:
--------------------------------------------------------------------------------
1 | #coding=utf-8
2 |
3 | """
4 | Description: 多文档格式转换工具
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import os,fnmatch
10 | from win32com import client as wc
11 | from win32com.client import Dispatch,gencache
12 |
13 |
14 | '''
15 | 功能描述:抽取文件文本信息
16 | 参数描述:1 filePath:文件路径 2 savePath: 指定保存路径
17 | '''
18 | def Files2Txt(filePath,savePath=''):
19 | try:
20 | # 1 切分文件上级目录和文件名
21 | dirs,filename = os.path.split(filePath)
22 | # print('目录:',dirs,'\n文件名:',filename)
23 |
24 | # 2 修改转化后的文件名
25 | typename = os.path.splitext(filename)[-1].lower() # 获取后缀
26 | new_name = TranType(filename,typename)
27 | # print('新的文件名:',new_name)
28 |
29 | # 3 文件转化后的保存路径
30 | if savePath=="": savePath = dirs
31 | else: savePath = savePath
32 | new_save_path = os.path.join(savePath,new_name)
33 | print('保存路径:',new_save_path)
34 |
35 | # 4 加载处理应用
36 | wordapp = wc.Dispatch('Word.Application')
37 | mytxt = wordapp.Documents.Open(filePath)
38 | mytxt.SaveAs(new_save_path,4)
39 | mytxt.Close()
40 | except Exception as e:
41 | pass
42 |
43 |
44 | '''
45 | 功能描述:根据文件后缀修改文件名
46 | 参数描述:1 filePath:文件路径 2 typename 文件后缀
47 | 返回数据:new_name 返回修改后的文件名
48 | '''
49 | def TranType(filename,typename):
50 | # 新的文件名称
51 | new_name = ""
52 | if typename == '.pdf' : # pdf->txt
53 | if fnmatch.fnmatch(filename,'*.pdf') :
54 | new_name = filename[:-4]+'.txt' # 截取".pdf"之前的文件名
55 | else: return
56 | elif typename == '.doc' or typename == '.docx' : # word->txt
57 | if fnmatch.fnmatch(filename, '*.doc') :
58 | new_name = filename[:-4]+'.txt'
59 | elif fnmatch.fnmatch(filename, '*.docx'):
60 | new_name = filename[:-5]+'.txt'
61 | else: return
62 | else:
63 | print('警告:\n您输入[',typename,']不合法,本工具支持pdf/doc/docx格式,请输入正确格式。')
64 | return
65 | return new_name
66 |
67 |
68 |
69 | if __name__ == '__main__':
70 | filePath1 = os.path.abspath(r'../dataSet/Corpus/wordtotxt/一种改进的朴素贝叶斯文本分类方法研究.doc')
71 | filePath2 = os.path.abspath(r'../dataSet/Corpus/pdftotxt/改进朴素贝叶斯文本分类方法研究.pdf')
72 | filePath3 = os.path.abspath(r'../dataSet/Corpus/wordtotxt/科技项目数据挖掘决策架构.docx')
73 | Files2Txt(filePath3)
--------------------------------------------------------------------------------
/ExtractText/TraverFiles.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 |
3 | """
4 | Description: 遍历读取文件名
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import os,time
10 |
11 |
12 | '''
13 | 功能描述:遍历目录处理子文件
14 | 参数描述: 1 rootDir 目标文件的根目录
15 | '''
16 | class TraversalFun():
17 | # 1 初始化
18 | def __init__(self,rootDir):
19 | self.rootDir = rootDir # 目录路径
20 |
21 | # 2 遍历目录文件
22 | def TraversalDir(self):
23 | TraversalFun.AllFiles(self,self.rootDir)
24 |
25 | # 3 递归遍历所有文件,并提供具体文件操作功能
26 | def AllFiles(self,rootDir):
27 | # 返回指定目录包含的文件或文件夹的名字的列表
28 | for lists in os.listdir(rootDir):
29 | # 待处理文件夹名字集合
30 | path = os.path.join(rootDir, lists)
31 | # 核心算法,对文件具体操作
32 | if os.path.isfile(path):
33 | print(os.path.abspath(path))
34 | # 递归遍历文件目录
35 | elif os.path.isdir(path):
36 | TraversalFun.AllFiles(self,path)
37 |
38 |
39 |
40 | if __name__ == '__main__':
41 | time_start=time.time()
42 |
43 | # 根目录文件路径
44 | rootDir = r"../dataSet/Corpus/EnPapers"
45 | tra=TraversalFun(rootDir) # 默认方法参数打印所有文件路径
46 | tra.TraversalDir() # 遍历文件并进行相关操作
47 |
48 | time_end=time.time()
49 | print('totally cost',time_end-time_start,'s')
--------------------------------------------------------------------------------
/ExtractText/__pycache__/ExtractTxt.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/ExtractText/__pycache__/ExtractTxt.cpython-35.pyc
--------------------------------------------------------------------------------
/ExtractText/pdf2txt.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 |
3 | """
4 | Description: PDF文件转化TXT文本
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import os,fnmatch
10 | from win32com import client as wc
11 | from win32com.client import Dispatch,gencache
12 |
13 |
14 | '''
15 | 功能描述:pdf文件转化txt文本
16 | 参数描述:1 filePath:文件路径 2 savePath: 指定保存路径
17 | '''
18 | def Pdf2Txt(filePath,savePath=''):
19 | # 1 切分文件上级目录和文件名
20 | dirs,filename = os.path.split(filePath)
21 | # print('目录:',dirs,'\n文件名:',filename)
22 |
23 | # 2 修改转化后的文件名
24 | new_name = ""
25 | if fnmatch.fnmatch(filename,'*.pdf') or fnmatch.fnmatch(filename,'*.PDF'):
26 | new_name = filename[:-4]+'.txt' # 截取".pdf"之前的文件名
27 | else: return
28 | print('新的文件名:',new_name)
29 |
30 | # 3 文件转化后的保存路径
31 | if savePath=="": savePath = dirs
32 | else: savePath = savePath
33 | pdf_to_txt = os.path.join(savePath,new_name)
34 | print('保存路径:',pdf_to_txt)
35 |
36 | # 4 加载处理应用,pdf转化txt
37 | wordapp = wc.Dispatch('Word.Application')
38 | mytxt = wordapp.Documents.Open(filePath)
39 | mytxt.SaveAs(pdf_to_txt,4)
40 | mytxt.Close()
41 |
42 |
43 |
44 | if __name__=='__main__':
45 | # 使用绝对路径
46 | filePath = os.path.abspath(r'../dataSet/Corpus/pdftotxt/2018年世界新闻自由日.pdf')
47 | # savePath = r'E:\\'
48 | Pdf2Txt(filePath)
49 |
--------------------------------------------------------------------------------
/ExtractText/word2txt.py:
--------------------------------------------------------------------------------
1 | #coding=utf-8
2 |
3 | """
4 | Description: Word文件转化TXT文本
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | Install package: pip install pypiwin32
8 | """
9 |
10 | import os,fnmatch
11 | from win32com import client as wc
12 | from win32com.client import Dispatch
13 |
14 |
15 | '''
16 | 功能描述:word文件转存txt文件,默认存储当前路径下;用户可以指定存储文件路径。
17 | 参数描述:1 filePath:文件路径 2 savePath: 指定保存路径
18 | '''
19 | def Word2Txt(filePath,savePath=''):
20 | # 1 切分文件上级目录和文件名
21 | dirs,filename = os.path.split(filePath)
22 | # print(dirs,'\n',filename)
23 |
24 | # 2 修改转化后的文件名
25 | new_name = ''
26 | if fnmatch.fnmatch(filename,'*.doc'):
27 | new_name = filename[:-4]+'.txt'
28 | elif fnmatch.fnmatch(filename,'*.docx'):
29 | new_name = filename[:-5]+'.txt'
30 | else: return
31 | print('->',new_name)
32 |
33 | # 3 文件转化后的保存路径
34 | if savePath=='': savePath = dirs
35 | else: savePath = savePath
36 | word_to_txt = os.path.join(savePath,new_name)
37 | print('->',word_to_txt)
38 |
39 | # 4 加载处理应用,word转化txt
40 | wordapp = wc.Dispatch('Word.Application')
41 | mytxt = wordapp.Documents.Open(filePath)
42 | mytxt.SaveAs(word_to_txt,4)
43 | mytxt.Close()
44 |
45 |
46 |
47 | if __name__=='__main__':
48 | filepath = os.path.abspath(r'../dataSet/Corpus/wordtotxt/一种改进的朴素贝叶斯文本分类方法研究.doc')
49 | # savepath = ''
50 | Word2Txt(filepath)
--------------------------------------------------------------------------------
/FeatureVec/30wVec.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:30万条新闻文本数据清洗
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import os,time
10 | from StopWords import *
11 | from wordbag import *
12 |
13 | #******************** 高效读取文件***********************************
14 | class loadFolders(object): # 迭代器
15 | def __init__(self, par_path):
16 | self.par_path = par_path
17 | def __iter__(self):
18 | for file in os.listdir(self.par_path):
19 | file_abspath = os.path.join(self.par_path, file)
20 | if os.path.isdir(file_abspath): # if file is a folder
21 | yield file_abspath
22 |
23 | class loadFiles(object):
24 | def __init__(self, par_path):
25 | self.par_path = par_path
26 | def __iter__(self):
27 | folders = loadFolders(self.par_path)
28 | for folder in folders: # level directory
29 | catg = folder.split(os.sep)[-1]
30 | for file in os.listdir(folder): # secondary directory
31 | file_path = os.path.join(folder, file)
32 | if os.path.isfile(file_path):
33 | this_file = open(file_path, 'rb') #rb读取方式更快
34 | content = this_file.read().decode('utf8')
35 | yield catg, content
36 | this_file.close()
37 |
38 |
39 |
40 | if __name__=='__main__':
41 | start = time.time()
42 |
43 | filepath = os.path.abspath(r'../dataSet/CSCMNews')
44 | files = loadFiles(filepath)
45 | n = 1 # n 表示抽样率, n抽1
46 | for i, msg in enumerate(files):
47 | if i % n == 0:
48 | catg = msg[0]
49 | content = msg[1]
50 | # 每个文档的TFIDF向量化-->所有词集(gensim)
51 | word_list = seg_doc(content)
52 | vocabList=createVocabList(word_list)
53 | bagvec = bagOfWords2VecMN(vocabList, word_list)
54 | tfidf = TFIDF(bagvec)
55 | if int(i/n) % 1000 == 0:
56 | print('{t} *** {i} \t docs has been dealed'
57 | .format(i=i, t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())),'\n',catg,':\t',tfidf)
58 |
59 | end = time.time()
60 | print('total spent times:%.2f' % (end-start)+ ' s')
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/FeatureVec/StopWords.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:自定义去停用词
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import re,jieba,sys
10 |
11 | # 加载自定义分词词典
12 | jieba.load_userdict("../dataSet/StopWord/user_dict.txt")
13 |
14 |
15 | #********************1 结巴中文分词***********************************
16 |
17 | # 利用jieba对文本进行分词,返回切词后的list
18 | def seg_doc(str_doc):
19 | # 1 正则处理原文本
20 | sent_list = str_doc.split('\n')
21 | # map内置高阶函数:一个函数f和list,函数f依次作用在list.
22 | sent_list = map(textParse, sent_list) # 正则处理,去掉一些字符,例如\u3000
23 |
24 | # 2 获取停用词
25 | stwlist = get_stop_words()
26 |
27 | # 3 分词并去除停用词
28 | word_2dlist = [rm_tokens(jieba.cut(part, cut_all=False),stwlist) for part in sent_list]
29 |
30 | # 4 合并列表
31 | word_list = sum(word_2dlist, [])
32 | return word_list
33 |
34 |
35 | # 正则对字符串清洗
36 | def textParse(str_doc):
37 | # 正则过滤掉特殊符号、标点、英文、数字等。
38 | # r1 = '[a-zA-Z0-9’!"#$%&\'()*+,-./::;;|<=>?@,—。?★、…【】《》?“”‘’![\\]^_`{|}~]+'
39 | # str_doc=re.sub(r1, ' ', str_doc)
40 |
41 | # 去掉字符
42 | str_doc = re.sub('\u3000', '', str_doc)
43 |
44 | # 去除空格
45 | # str_doc=re.sub('\s+', ' ', str_doc)
46 |
47 | # 去除换行符
48 | # str_doc = str_doc.replace('\n',' ')
49 | return str_doc
50 |
51 |
52 | # 创建停用词列表
53 | def get_stop_words(path=r'../dataSet/StopWord/NLPIR_stopwords.txt'):
54 | file = open(path, 'r',encoding='utf-8').read().split('\n')
55 | return set(file)
56 |
57 | # 去掉一些停用词和数字
58 | def rm_tokens(words,stwlist):
59 | words_list = list(words)
60 | stop_words = stwlist
61 | for i in range(words_list.__len__())[::-1]:
62 | if words_list[i] in stop_words: # 去除停用词
63 | words_list.pop(i)
64 | elif words_list[i].isdigit(): # 去除数字
65 | words_list.pop(i)
66 | elif len(words_list[i]) == 1: # 去除单个字符
67 | words_list.pop(i)
68 | elif words_list[i] == " ": # 去除空字符
69 | words_list.pop(i)
70 | return words_list
71 |
72 |
73 | # 读取文本信息
74 | def readFile(path):
75 | str_doc = ""
76 | with open(path,'r',encoding='utf-8') as f:
77 | str_doc = f.read()
78 | return str_doc
79 |
80 |
81 |
82 | if __name__=='__main__':
83 | # 1 读取文本
84 | path= r'../dataSet/CSCMNews/体育/0.txt'
85 | str_doc = readFile(path)
86 | # print(str_doc)
87 |
88 | # 2 分词去停用词
89 | word_list = seg_doc(str_doc)
90 | print(word_list)
--------------------------------------------------------------------------------
/FeatureVec/TFIDF.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description: 利用sklearn计算tfidf值特征
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from StopWords import readFile,seg_doc
10 | from sklearn.feature_extraction.text import TfidfTransformer
11 | from sklearn.feature_extraction.text import CountVectorizer
12 |
13 |
14 | # 利用sklearn计算tfidf值特征
15 | def sklearn_tfidf_feature(corpus=None):
16 | # 构建词汇表
17 | vectorizer = CountVectorizer()
18 | # 该类会统计每个词语的tf-idf权值
19 | transformer = TfidfTransformer()
20 | # 第一个fit_transform是计算tf-idf,第二个fit_transform是将文本转为词频矩阵
21 | tfidf = transformer.fit_transform(vectorizer.fit_transform(corpus))
22 | # 获取词袋模型中的所有词语
23 | word = vectorizer.get_feature_names()
24 | # 元素a[i][j]表示j词在i类文本中的tf-idf权重
25 | weight = tfidf.toarray()
26 | # 第一个for遍历所有文本,第二个for便利某一类文本下的词语权重
27 | for i in range(len(weight)):
28 | print(u"-------这里输出第", i, u"类文本的词语tf-idf权重------")
29 | for j in range(len(word)):
30 | print(word[j], weight[i][j])
31 |
32 |
33 |
34 |
35 | if __name__=='__main__':
36 | # corpus参数样例数据如下:
37 | corpus = ["我 来到 成都 成都 春熙路 很 开心",
38 | "今天 在 宽窄巷子 耍 了 一天 ",
39 | "成都 整体 来说 还是 挺 安逸 的",
40 | "成都 的 美食 真 巴适 惨 了"]
41 |
42 | sklearn_tfidf_feature(corpus)
--------------------------------------------------------------------------------
/FeatureVec/__pycache__/StopWords.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/FeatureVec/__pycache__/StopWords.cpython-35.pyc
--------------------------------------------------------------------------------
/FeatureVec/__pycache__/StopWords.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/FeatureVec/__pycache__/StopWords.cpython-37.pyc
--------------------------------------------------------------------------------
/FeatureVec/__pycache__/lossval.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/FeatureVec/__pycache__/lossval.cpython-35.pyc
--------------------------------------------------------------------------------
/FeatureVec/__pycache__/lossval.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/FeatureVec/__pycache__/lossval.cpython-37.pyc
--------------------------------------------------------------------------------
/FeatureVec/__pycache__/wordbag.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/FeatureVec/__pycache__/wordbag.cpython-35.pyc
--------------------------------------------------------------------------------
/FeatureVec/__pycache__/wordbag.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/FeatureVec/__pycache__/wordbag.cpython-37.pyc
--------------------------------------------------------------------------------
/FeatureVec/lossval.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:处理数据缺失值
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | # 处理数据缺失值
10 | # 使用可用特征的均值来填补缺失值
11 | # 使用特殊值来填补缺失值如-1,0
12 | # 忽略有缺失值的样本
13 | # 使用相似样本的均值填补缺失值
14 | # 使用机器学习算法预测缺失值
15 |
16 | import numpy
17 | from numpy import *
18 |
19 | '''加载数据集'''
20 | def loadDataSet(fileName, delim='\t'):
21 | fr = open(fileName)
22 | stringArr = [line.strip().split(delim) for line in fr.readlines()]
23 | # print(stringArr) # 二维数组
24 | datArr = [list(map(float, line)) for line in stringArr]
25 | # print(mat(datArr))
26 | return mat(datArr)
27 |
28 |
29 | '''将NaN替换成平均值函数'''
30 | def replaceNanWithMean():
31 | datMat = loadDataSet('../dataSet/files/dataset.data',' ')
32 | numFeat = shape(datMat)
33 | # print(numFeat[1]-1) # 特征数3
34 | for i in range(numFeat[1]-1):
35 | # 对value不为NaN的求均值,A 返回矩阵基于的数组
36 | # print(datMat[nonzero(~isnan(datMat[:, i].A))[0],i]) # 列特征非nan数据
37 | meanVal = mean(datMat[nonzero(~isnan(datMat[:, i].A))[0], i])
38 | # 将value为NaN的值赋值为均值
39 | datMat[nonzero(isnan(datMat[:, i].A))[0],i] = meanVal
40 | return datMat
41 |
42 |
43 | # if __name__=='__main__':
44 | # 加载数据集
45 | # loadDataSet('../dataSet/files/dataset.data',' ')
46 |
47 | # 均值填补缺失值
48 | # datMat = replaceNanWithMean()
49 | # print(datMat)
50 |
51 |
52 |
53 |
54 | #************3 Pandas 处理丢失值*******************
55 | # 机器学习和数据挖掘等领域由于数据缺失导致的数据质量差,
56 | # 在模型预测的准确性上面临着严重的问题。
57 |
58 | import pandas as pd
59 | import numpy as np
60 |
61 | datMat = loadDataSet('../dataSet/files/dataset.data',' ')
62 | df = pd.DataFrame(datMat)
63 | # df = pd.DataFrame(datMat, index=range(datMat.shape[0]),columns=['one', 'two', 'three', 'four'] )
64 | # 使用重构索引(reindexing),创建了一个缺少值的DataFrame。 输出中,NaN表示不是数字的值
65 | df = df.reindex(range(datMat.shape[0]+5))
66 |
67 | # 1 重构矩阵
68 | # print (df) # 打印矩阵
69 |
70 | # 2 检查是否为空
71 | # print (df.isnull())
72 | # print (df['one'].notnull()) # 检查第一列是否为空
73 |
74 | # 3 均值填充法:NAN视为0.若数据是 NAN和是 NAN
75 |
76 | # lossVs = [df[col].mean() for col in range(datMat.shape[1])] # 计算特征列均值
77 | # print(lossVs)
78 | # lists= [ list(df[i].fillna(lossVs[i])) for i in range(len(lossVs)) ]
79 | # print(mat(lists).T)
80 |
81 | # lists.append(list(df[0].fillna(lossVs[0])))
82 | # lists.append(list(df[1].fillna(lossVs[1])))
83 | # lists.append(list(df[2].fillna(lossVs[2])))
84 | # lists.append(list(df[3].fillna(lossVs[3])))
85 |
86 |
87 | # 4 其他缺失值处理方法
88 | # 4.1 用标量值替换NaN
89 | # print ("NaN replaced with '0':")
90 | # print (df.fillna(0))
91 |
92 | # 4.2 前进和后退:pad/fill 和 bfill/backfill
93 | # print (df.fillna(method='pad'))
94 | # print (df.fillna(method='backfill'))
95 |
96 | # 4.3 丢失缺少的值:axis=0在行上应用,axis=1在列上应用
97 | # print (df.dropna(axis=0))
98 |
99 | # 4.4 忽略无效值
100 | # print("df.dropna():\n{}\n".format(df.dropna()))
--------------------------------------------------------------------------------
/FeatureVec/normdata.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:不均衡的数据归一化处理方法
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from numpy import *
10 | from lossval import replaceNanWithMean
11 |
12 |
13 | '''数值归一化:特征值转化为0-1之间:newValue = (oldValue-min)/(max-min)'''
14 | def norm_dataset(dataset):
15 | minVals = dataset.min(0) # 参数0是取得列表中的最小值,而不是行中最小值
16 | maxVals = dataset.max(0)
17 | ranges = maxVals - minVals
18 |
19 | normdataset = zeros(shape(dataset)) # 生成原矩阵一样大小的0矩阵
20 | m = dataset.shape[0]
21 |
22 | # tile:复制同样大小的矩阵
23 | molecular = dataset - tile(minVals,(m,1)) # 分子: (oldValue-min)
24 | Denominator = tile(ranges,(m,1)) # 分母:(max-min)
25 | normdataset = molecular / Denominator # 归一化结果。
26 |
27 | print('归一化的数据结果:\n'+str(normdataset))
28 | return normdataset,ranges,minVals
29 |
30 |
31 |
32 | if __name__=='__main__':
33 | dataset = replaceNanWithMean()
34 | # print(dataset)
35 | normdataset,ranges,minVals = norm_dataset(dataset[:,:-1])
36 | # print(normdataset[:100])
37 |
38 |
39 |
--------------------------------------------------------------------------------
/FeatureVec/similar.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:相似度计算
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from numpy import linalg as la
10 | from numpy import *
11 |
12 | '''原矩阵
13 | 列向量为商品的类别
14 | 行向量为用户对商品的评分
15 | 可以根据相似度推荐商品
16 | '''
17 | def loadExData():
18 | return [[1, 1, 1, 0, 0],
19 | [2, 2, 2, 0, 0],
20 | [1, 1, 1, 0, 0],
21 | [5, 5, 5, 0, 0],
22 | [1, 1, 0, 2, 2],
23 | [0, 0, 0, 3, 3],
24 | [0, 0, 0, 1, 1]]
25 |
26 |
27 | '''基于欧氏距离相似度计算,假定inA和inB 都是列向量
28 | 相似度=1/(1+距离),相似度介于0-1之间
29 | norm:范式计算,默认是2范数,即:sqrt(a^2+b^2+...)
30 | '''
31 | def ecludSim(inA, inB):
32 | return 1.0/(1.0 + la.norm(inA - inB))
33 |
34 |
35 | '''皮尔逊相关系数
36 | 范围[-1, 1],归一化后[0, 1]即0.5 + 0.5 *
37 | 相对于欧式距离,不敏感皮尔逊相关系数
38 | '''
39 | def pearsSim(inA, inB):
40 | return 0.5 + 0.5 * corrcoef(inA, inB, rowvar=0)[0][1]
41 |
42 |
43 | '''计算余弦相似度
44 | 如果夹角为90度相似度为0;两个向量的方向相同,相似度为1.0
45 | 余弦取值-1到1之间,归一化到0与1之间即:相似度=0.5 + 0.5*cosθ
46 | 余弦相似度cosθ=(A*B/|A|*|B|)
47 | '''
48 | def cosSim(inA, inB):
49 | num = float(inA.T*inB) # 矩阵相乘
50 | denom = la.norm(inA)*la.norm(inB) # 默认是2范数
51 | return 0.5 + 0.5*(num/denom)
52 |
53 |
54 |
55 | if __name__=='__main__':
56 | # 3 相似度计算
57 | # 3.1 计算欧氏距离,比较第一列商品A和第四列商品D的相似率
58 | myMat = mat(loadExData())
59 | # print(myMat[:, 3])
60 | print('欧氏距离\n',ecludSim(myMat[:, 0], myMat[:, 3]))
61 | # 3.2 计算余弦相似度
62 | print('余弦相似度距离\n',cosSim(myMat[:, 0], myMat[:, 3]))
63 | # 3.3 计算皮尔逊相关系数
64 | print('皮尔逊距离\n',pearsSim(myMat[:, 0], myMat[:, 3]))
65 |
66 |
--------------------------------------------------------------------------------
/FeatureVec/splitData.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:解析数据文件,返回特征集和标签
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | '''
10 | 特征数据集:
11 | 特征1:年均投入时间(min)
12 | 特征2:玩游戏占时间百分比
13 | 特征3:每天看综艺的时间(h)
14 |
15 | 标签集:
16 | 1:学习专注
17 | 2:学习正常
18 | 3:比较贪玩
19 | '''
20 |
21 | import os
22 | from numpy import *
23 |
24 |
25 | def file_matrix(filename):
26 | f = open(filename)
27 | arrayLines = f.readlines()
28 |
29 | returnMat = zeros((len(arrayLines),3)) # 特征数据集
30 | classLabelVactor = [] # 标签集
31 | index = 0
32 | for line in arrayLines:
33 | listFromLine = line.strip().split('\t') # 分析数据,空格处理
34 | returnMat[index,:] = listFromLine[0:3]
35 | classLabelVactor.append(int(listFromLine[-1]))
36 | index +=1
37 | return returnMat,classLabelVactor
38 |
39 |
40 |
41 | if __name__=='__main__':
42 | path = os.path.abspath(r'../dataSet/files/dataset.txt')
43 | returnMat,classLabelVactor=file_matrix(path)
44 | print('数据集:\n',returnMat,'\n标签集:\n',classLabelVactor)
--------------------------------------------------------------------------------
/FeatureVec/wordbag.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:词袋模型
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from numpy import *
10 | import numpy as np
11 |
12 |
13 | '''创建数据集:单词列表postingList, 所属类别classVec'''
14 | def loadDataSet():
15 | # corpus参数样例数据如下:
16 | corpus =[]
17 | tiyu = ['姚明', '我来', '承担', '连败', '巨人', '宣言', '酷似', '当年', '麦蒂', '新浪', '体育讯', '北京', '时间', '消息', '休斯敦', '纪事报', '专栏', '记者', '乔纳森', '费根', '报道', '姚明', '渴望', '一场', '胜利', '当年', '队友', '麦蒂', '惯用', '句式']
18 | yule = ['谢婷婷', '模特', '酬劳', '仅够', '生活', '风光', '背后', '惨遭', '拖薪', '新浪', '娱乐', '金融', '海啸', 'blog', '席卷', '全球', '模特儿', '酬劳', '被迫', '打折', '全职', 'Model', '谢婷婷', '业界', '工作量', '有增无减', '收入', '仅够', '糊口', '拖薪']
19 | jioayu = ['名师', '解读', '四六级', '阅读', '真题', '技巧', '考前', '复习', '重点', '历年', '真题', '阅读', '听力', '完形', '提升', '空间', '天中', '题为', '主导', '考过', '六级', '四级', '题为', '主导', '真题', '告诉', '方向', '会考', '题材', '包括']
20 | shizheng = ['美国', '军舰', '抵达', '越南', '联合', '军演', '中新社', '北京', '日电', '杨刚', '美国', '海军', '第七', '舰队', '三艘', '军舰', '抵达', '越南', '岘港', '为期', '七天', '美越', '南海', '联合', '军事训练', '拉开序幕', '美国', '海军', '官方网站', '消息']
21 |
22 | corpus.append(tiyu)
23 | corpus.append(yule)
24 | corpus.append(jioayu)
25 | corpus.append(shizheng)
26 |
27 | classVec = ['体育','娱乐','教育','时政']
28 | return corpus,classVec
29 |
30 |
31 | '''获取所有单词的集合:返回不含重复元素的单词列表'''
32 | def createVocabList(dataSet):
33 | vocabSet = set([])
34 | for document in dataSet:
35 | vocabSet = vocabSet | set(document) # 操作符 | 用于求两个集合的并集
36 | # print(vocabSet)
37 | return list(vocabSet)
38 |
39 |
40 |
41 | '''文档词袋模型构建数据矩阵'''
42 | def bagOfWords2VecMN(vocabList, DataSet):
43 | # 1 所有文档的词向量
44 | VecList = []
45 | for inputSet in DataSet:
46 | # print('-->',inputSet)
47 | returnVec = [0] * len(vocabList)
48 | for word in inputSet:
49 | if word in vocabList:
50 | returnVec[vocabList.index(word)] += 1
51 | VecList.append(returnVec)
52 | return VecList
53 |
54 |
55 |
56 | '''词袋模型转化为tf-idf计算
57 | 实现自动摘要
58 | https://www.cnblogs.com/cppb/p/5976266.html
59 | '''
60 | def TFIDF(bagvec):
61 | # 词频 = 某个词在文章中出现的总次数/文章中出现次数最多的词的个数
62 | tf = [ doc/sum(doc) for doc in bagvec]
63 | # 逆文档频率(IDF) = log(词料库的文档总数/包含该词的文档数+1)
64 | m = len(bagvec) # 词料库的文档总数
65 | ndw =sum(mat(bagvec).T!=0,axis=1).T # 包含该词的文档数
66 | idf = [ log(m/(t+1)) for t in ndw]
67 | tfidf = tf * np.array(idf)
68 | # 设置保留小数位
69 | np.set_printoptions(precision=2)
70 | # print('tf:\n',mat(tf),'\nndw:\n',ndw,'\nidf:\n',idf,'\ntfidf:\n',tfidf)
71 | return tfidf
72 |
73 |
74 |
75 | if __name__=='__main__':
76 | # 1 打印数据集和标签
77 | dataSet,classlab = loadDataSet()
78 | print('数据集:\n',mat(dataSet),'\n标签集:\n',mat(classlab))
79 |
80 | # 2 获取所有单词的集合
81 | vocabList=createVocabList(dataSet)
82 | print('\n词汇列表:\n',vocabList)
83 |
84 | #***********特征词转向量*********************
85 | # 3 词袋模型:文本向量转化
86 | bagvec = bagOfWords2VecMN(vocabList, dataSet)
87 | print('词袋模型:\n',mat(bagvec))
88 |
89 | # 4 tf-idf计算
90 | tfidf = TFIDF(bagvec)
91 | print('tf-idf:\n ',tfidf)
92 |
93 |
--------------------------------------------------------------------------------
/FeatureVec/wordset.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:词集模型
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from numpy import *
10 | import numpy as np
11 |
12 |
13 | '''创建数据集:单词列表postingList, 所属类别classVec'''
14 | def loadDataSet():
15 | # corpus参数样例数据如下:
16 | corpus =[]
17 | tiyu = ['姚明', '我来', '承担', '连败', '巨人', '宣言', '酷似', '当年', '麦蒂', '新浪', '体育讯', '北京', '时间', '消息', '休斯敦', '纪事报', '专栏', '记者', '乔纳森', '费根', '报道', '姚明', '渴望', '一场', '胜利', '当年', '队友', '麦蒂', '惯用', '句式']
18 | yule = ['谢婷婷', '模特', '酬劳', '仅够', '生活', '风光', '背后', '惨遭', '拖薪', '新浪', '娱乐', '金融', '海啸', 'blog', '席卷', '全球', '模特儿', '酬劳', '被迫', '打折', '全职', 'Model', '谢婷婷', '业界', '工作量', '有增无减', '收入', '仅够', '糊口', '拖薪']
19 | jioayu = ['名师', '解读', '四六级', '阅读', '真题', '技巧', '考前', '复习', '重点', '历年', '真题', '阅读', '听力', '完形', '提升', '空间', '天中', '题为', '主导', '考过', '六级', '四级', '题为', '主导', '真题', '告诉', '方向', '会考', '题材', '包括']
20 | shizheng = ['美国', '军舰', '抵达', '越南', '联合', '军演', '中新社', '北京', '日电', '杨刚', '美国', '海军', '第七', '舰队', '三艘', '军舰', '抵达', '越南', '岘港', '为期', '七天', '美越', '南海', '联合', '军事训练', '拉开序幕', '美国', '海军', '官方网站', '消息']
21 |
22 | corpus.append(tiyu)
23 | corpus.append(yule)
24 | corpus.append(jioayu)
25 | corpus.append(shizheng)
26 |
27 | classVec = ['体育','娱乐','教育','时政']
28 | return corpus,classVec
29 |
30 |
31 |
32 | '''获取所有单词的集合:返回不含重复元素的单词列表'''
33 | def createVocabList(dataSet):
34 | vocabSet = set([])
35 | for document in dataSet:
36 | vocabSet = vocabSet | set(document) # 操作符 | 用于求两个集合的并集
37 | # print(vocabSet)
38 | return list(vocabSet)
39 |
40 |
41 |
42 | '''词集模型构建数据矩阵
43 | 遍历文档中的所有单词,如果出现了词汇表中的单词,则将输出的文档向量中的对应值设为1
44 | vocabList:单词的集合
45 | DataSet:数据文档
46 | '''
47 | def setOfWords2Vec(vocabList, DataSet):
48 | # 1 所有文档的词向量
49 | VecList = []
50 | for inputSet in DataSet:
51 | # print('-->',inputSet) # 每个文档
52 | # 2 创建一个和词汇表等长的向量,并将其元素都设置为0
53 | returnVec = [0] * len(vocabList)
54 | # 如果单词在词汇表则修正1
55 | for word in inputSet:
56 | if word in vocabList:
57 | returnVec[vocabList.index(word)] = 1
58 | # 追加所有文档词向量列表
59 | VecList.append(returnVec)
60 | return VecList
61 |
62 |
63 |
64 |
65 | '''词集模型转化为tf-idf计算
66 | 实现自动摘要
67 | https://www.cnblogs.com/cppb/p/5976266.html
68 | '''
69 | def TFIDF(bagvec):
70 | # 词频 = 某个词在文章中出现的总次数/文章中出现次数最多的词的个数
71 | tf = [ doc/sum(doc) for doc in bagvec]
72 | # 逆文档频率(IDF) = log(词料库的文档总数/包含该词的文档数+1)
73 | m = len(bagvec) # 词料库的文档总数
74 | ndw =sum(mat(bagvec).T!=0,axis=1).T # 包含该词的文档数
75 | idf = [ log(m/(t+1)) for t in ndw]
76 | tfidf = tf * np.array(idf)
77 | # print('tf:\n',mat(tf),'\nndw:\n',ndw,'\nidf:\n',idf,'\ntfidf:\n',tfidf)
78 | # print(log(4/5))
79 | return tfidf
80 |
81 |
82 |
83 | if __name__=='__main__':
84 | # 1 打印数据集和标签
85 | dataSet,classlab = loadDataSet()
86 | print('数据集:\n',mat(dataSet),'\n标签集:\n',mat(classlab))
87 |
88 | # 2 获取所有单词的集合
89 | vocabList=createVocabList(dataSet)
90 | print('\n词汇列表:\n',vocabList)
91 |
92 | #***********特征词转向量*********************
93 | # 3 词集模型:文本向量转化
94 | setvec = setOfWords2Vec(vocabList, dataSet)
95 | print('词集模型:\n',mat(setvec))
96 |
97 | # 4 tf-idf计算
98 | tfidf = TFIDF(setvec)
99 | print('tf-idf:\n',tfidf)
100 |
--------------------------------------------------------------------------------
/GensimVec/30wVec.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:实战案例5:Gensim实现新闻文本特征向量化
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import os,time,sys
10 | from mydict import *
11 | from StopWords import *
12 | from gensim import corpora, models
13 |
14 |
15 |
16 | #******************** 高效读取文件***********************************
17 | class loadFolders(object): # 迭代器
18 | def __init__(self, par_path):
19 | self.par_path = par_path
20 | def __iter__(self):
21 | for file in os.listdir(self.par_path):
22 | file_abspath = os.path.join(self.par_path, file)
23 | if os.path.isdir(file_abspath): # if file is a folder
24 | yield file_abspath
25 |
26 | class loadFiles(object):
27 | def __init__(self, par_path):
28 | self.par_path = par_path
29 | def __iter__(self):
30 | folders = loadFolders(self.par_path)
31 | for folder in folders: # level directory
32 | catg = folder.split(os.sep)[-1]
33 | for file in os.listdir(folder): # secondary directory
34 | file_path = os.path.join(folder, file)
35 | if os.path.isfile(file_path):
36 | this_file = open(file_path, 'rb') #rb读取方式更快
37 | content = this_file.read().decode('utf8')
38 | yield catg, content
39 | this_file.close()
40 |
41 |
42 |
43 | if __name__=='__main__':
44 | start = time.time()
45 |
46 | n = 5 # n 表示抽样率, n抽1
47 | path_doc_root = '../dataSet/CSCMNews' # 根目录 即存放按类分类好的文本数据集
48 | path_tmp = '../dataSet/files/CSCMNews_model' # 存放中间结果的位置
49 | path_dictionary = os.path.join(path_tmp, 'CSCMNews.dict') # 存放词典
50 | path_tmp_tfidf = os.path.join(path_tmp, 'tfidf_corpus') # 存放tfidf
51 |
52 |
53 | if not os.path.exists(path_tmp):
54 | os.makedirs(path_tmp)
55 | # ===================================================================
56 | # 第一阶段,遍历文档,生成词典,并去掉频率较少的项
57 | # 如果指定的位置没有词典,则重新生成一个。如果有,则跳过该阶段
58 | if not os.path.exists(path_dictionary):
59 | print('=== 未检测到有词典存在,开始遍历生成词典 ===')
60 | dictionary = corpora.Dictionary()
61 | files = loadFiles(path_doc_root)
62 | for i, msg in enumerate(files):
63 | if i % n == 0:
64 | catg = msg[0]
65 | content = msg[1]
66 | content = seg_doc(content)
67 | dictionary.add_documents([content])
68 | if int(i/n) % 1000 == 0:
69 | print('{t} *** {i} \t docs has been dealed'
70 | .format(i=i, t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())))
71 | # 去掉词典中出现次数过少的
72 | small_freq_ids = [tokenid for tokenid, docfreq in dictionary.dfs.items() if docfreq < 5 ]
73 | dictionary.filter_tokens(small_freq_ids)
74 | dictionary.compactify() # 从新产生连续的编号
75 | dictionary.save(path_dictionary)
76 | print('=== 词典已经生成 ===')
77 | else:
78 | print('=== 检测到词典已经存在,跳过该阶段 ===')
79 |
80 | # ===================================================================
81 | # 第二阶段, 开始将文档转化成tfidf
82 | dictionary = None
83 | if not os.path.exists(path_tmp_tfidf):
84 | print('=== 未检测到有tfidf文件夹存在,开始生成tfidf向量 ===')
85 | # 如果指定的位置没有tfidf文档,则生成一个。如果有,则跳过该阶段
86 | if not dictionary: # 如果跳过了第一阶段,则从指定位置读取词典
87 | dictionary = corpora.Dictionary.load(path_dictionary)
88 | os.makedirs(path_tmp_tfidf)
89 | files = loadFiles(path_doc_root)
90 | tfidf_model = models.TfidfModel(dictionary=dictionary)
91 | corpus_tfidf = {}
92 | for i, msg in enumerate(files):
93 | if i % n == 0:
94 | catg = msg[0]
95 | content = msg[1]
96 | word_list = seg_doc(content)
97 | file_bow = dictionary.doc2bow(word_list)
98 | file_tfidf = tfidf_model[file_bow]
99 | tmp = corpus_tfidf.get(catg, [])
100 | tmp.append(file_tfidf)
101 | if tmp.__len__() == 1:
102 | corpus_tfidf[catg] = tmp
103 | if i % 10000 == 0:
104 | print('{i} files is dealed'.format(i=i))
105 | # 将tfidf中间结果储存起来
106 | catgs = list(corpus_tfidf.keys())
107 | for catg in catgs:
108 | corpora.MmCorpus.serialize('{f}{s}{c}.mm'.format(f=path_tmp_tfidf, s=os.sep, c=catg),corpus_tfidf.get(catg),id2word=dictionary)
109 | print('catg {c} has been transformed into tfidf vector'.format(c=catg))
110 | print('=== tfidf向量已经生成 ===')
111 | else:
112 | print('=== 检测到tfidf向量已经生成,跳过该阶段 ===')
113 |
114 | end = time.time()
115 | print('total spent times:%.2f' % (end-start)+ ' s')
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/GensimVec/HDP.py:
--------------------------------------------------------------------------------
1 |
2 | # coding:utf8
3 |
4 | """
5 | Description:HDP 分层狄利克雷过程
6 | Author:伏草惟存
7 | Prompt: code in Python3 env
8 | """
9 |
10 | from mydict import *
11 | from gensim import corpora, models
12 | from gensim.models.doc2vec import Doc2Vec, TaggedDocument
13 | import pickle as pkl
14 |
15 |
16 | '''
17 | 狄利克雷分布通俗讲解
18 | https://blog.csdn.net/yan456jie/article/details/52170772
19 |
20 | 其不同之处有两点:
21 | 1、HDP中引入了Dirichlet过程,而LDA中是Dirichlet分布。
22 | 2、在表示上,HDP中的分布本身是可以作为一个变量的。
23 | '''
24 |
25 | ## 分层狄利克雷过程HDP
26 | def gensim_Corpus(corpus=None):
27 | dictionary = corpora.Dictionary(corpus)
28 | # 1 doc_bow转化为tfidf向量
29 | doc_bow_corpus = [dictionary.doc2bow(doc_cut) for doc_cut in corpus]
30 | tfidf_model = models.TfidfModel(dictionary=dictionary)
31 | tfidf_corpus = [tfidf_model[doc_bow] for doc_bow in doc_bow_corpus]
32 | print('doc_bow转换成对应的tfidf_doc向量:\n',tfidf_corpus)
33 |
34 | # 2 分层狄利克雷过程(Hierarchical Dirichlet Process,HDP ,一种无参数贝叶斯方法)
35 | hdp_model = models.HdpModel(doc_bow_corpus, id2word=dictionary)
36 | hdp_corpus = [hdp_model[doc_bow] for doc_bow in doc_bow_corpus] # 转换成HDP向量
37 | print('HDP :\n',hdp_corpus)
38 |
39 | # 3 将RP模型存储到磁盘上
40 | savepath =r'../dataSet/files/hdp_model.pkl'
41 | hdp_file = open(savepath, 'wb')
42 | pkl.dump(hdp_model, hdp_file)
43 | hdp_file.close()
44 | print('--- HDP模型已经生成 ---')
45 |
46 | if __name__=='__main__':
47 | # corpus参数样例数据如下:
48 | corpus,classVec = loadDataSet()
49 | gensim_Corpus(corpus)
50 |
--------------------------------------------------------------------------------
/GensimVec/LDA.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:LDA 隐含狄利克雷分布
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from mydict import *
10 | from gensim import corpora, models
11 | from gensim.models.doc2vec import Doc2Vec, TaggedDocument
12 | import pickle as pkl
13 |
14 | '''
15 | 作者:-柚子皮-
16 | 主题模型TopicModel:隐含狄利克雷分布LDA
17 | https://blog.csdn.net/pipisorry/article/details/42649657
18 |
19 | 隐含狄利克雷分布简称LDA(Latent Dirichlet allocation),首先由吴恩达等人于2003年提出,目前在文本挖掘领域包括文本主题识别、文本分类以及文本相似度计算方面都有应用。
20 |
21 | LDA是一种典型的词袋模型,即它认为一篇文档是由一组词构成的一个集合,词与词之间没有顺序以及先后的关系。一篇文档可以包含多个主题,文档中每一个词都由其中的一个主题生成。
22 | 它是一种主题模型,它可以将文档集中每篇文档的主题按照概率分布的形式给出;
23 | 同时是一种无监督学习算法,在训练时不需要手工标注的训练集,需要的仅仅是文档集以及指定主题的数量k即可;
24 | 此外LDA的另一个优点则是,对于每一个主题均可找出一些词语来描述它;
25 |
26 | LDA可以被认为是一种聚类算法:
27 | 主题对应聚类中心,文档对应数据集中的例子。
28 | 主题和文档在特征空间中都存在,且特征向量是词频向量。
29 | LDA不是用传统的距离来衡量一个类簇,它使用的是基于文本文档生成的统计模型的函数。
30 | '''
31 |
32 |
33 | # 生成lda特征(主题模型)
34 | def gensim_Corpus(corpus=None):
35 | dictionary = corpora.Dictionary(corpus)
36 | # 1 doc_bow转化为tfidf向量
37 | doc_bow_corpus = [dictionary.doc2bow(doc_cut) for doc_cut in corpus]
38 | tfidf_model = models.TfidfModel(dictionary=dictionary) # 生成tfidf模型
39 | # 将每doc_bow转换成对应的tfidf_doc向量
40 | tfidf_corpus = [tfidf_model[doc_bow] for doc_bow in doc_bow_corpus]
41 | print('doc_bow转换成对应的tfidf_doc向量:\n',tfidf_corpus)
42 |
43 | lda_model = models.LdaModel(corpus=tfidf_corpus, id2word=dictionary, num_topics=10) # 生成lda model
44 | # 2 生成corpus of LDA
45 | lda_corpus = [lda_model[tfidf_doc] for tfidf_doc in tfidf_corpus] # 转换成lda向量
46 | print('LDA生成主题:\n',lda_corpus)
47 |
48 | # 3 将LDA模型存储到磁盘上
49 | savepath =r'../dataSet/files/lda_model.pkl'
50 | lda_file = open(savepath, 'wb')
51 | pkl.dump(lda_model, lda_file)
52 | lda_file.close()
53 | print('--- lda模型已经生成 ---')
54 |
55 | if __name__=='__main__':
56 | # corpus参数样例数据如下:
57 | corpus,classVec = loadDataSet()
58 | gensim_Corpus(corpus)
59 |
--------------------------------------------------------------------------------
/GensimVec/LSA.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:LSA/LSI 潜在语义分析/索引
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from mydict import *
10 | from gensim import corpora, models
11 | from gensim.models.doc2vec import Doc2Vec, TaggedDocument
12 | import pickle as pkl
13 | # python的pickle模块实现了基本的数据序列和反序列化。
14 | # 通过pickle模块的序列化操作我们能够将程序中运行的对象信息保存到文件中去,永久存储。
15 | # 通过pickle模块的反序列化操作,我们能够从文件中创建上一次程序保存的对象。
16 |
17 | '''
18 | 作者:黄小猿
19 | 主题模型(LDA)(一)--通俗理解与简单应用
20 | https://blog.csdn.net/qq_39422642/article/details/78730662
21 |
22 | 什么是LDA?
23 | 它是一种无监督的贝叶斯模型。
24 | 是一种主题模型,它可以将文档集中的每篇文档按照概率分布的形式给出。
25 | 是一种无监督学习,在训练时不需要手工标注的训练集,需要的是文档集和指定主题的个数。
26 | 是一种典型的词袋模型,它认为一篇文档是由一组词组成的集合,词与词之间没有顺序和先后关系。
27 | '''
28 |
29 | # LSA 潜在语义分析
30 | def gensim_Corpus(corpus=None):
31 | dictionary = corpora.Dictionary(corpus)
32 | # 1 doc_bow转化成tfidf向量
33 | doc_bow_corpus = [dictionary.doc2bow(doc_cut) for doc_cut in corpus]
34 | tfidf_model = models.TfidfModel(dictionary=dictionary) # 生成tfidf模型
35 | tfidf_corpus = [tfidf_model[doc_bow] for doc_bow in doc_bow_corpus] # 将每doc_bow转换成对应的tfidf_doc向量
36 | print('doc_bow转换成对应的tfidf_doc向量:\n',tfidf_corpus)
37 |
38 | # 2 生成lsi model
39 | lsi_model = models.LsiModel(corpus=tfidf_corpus, id2word=dictionary, num_topics=10)
40 | # 转换成lsi向量
41 | lsi_corpus = [lsi_model[tfidf_doc] for tfidf_doc in tfidf_corpus]
42 | print('LSA生成主题:\n',lsi_corpus)
43 |
44 | # 3 将lsi模型存储到磁盘上
45 | savepath =r'../dataSet/files/lsi_model.pkl'
46 | lsi_file = open(savepath, 'wb')
47 | pkl.dump(lsi_model, lsi_file)
48 | lsi_file.close()
49 | print('--- lsi模型已经生成 ---')
50 |
51 |
52 | if __name__=='__main__':
53 | # corpus参数样例数据如下:
54 | corpus,classVec = loadDataSet()
55 | gensim_Corpus(corpus)
56 |
--------------------------------------------------------------------------------
/GensimVec/LSI.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:生成lsi特征(潜在语义索引)
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from gensim import corpora, models
10 | from gensim.models.doc2vec import Doc2Vec, TaggedDocument
11 | from mydict import *
12 | import pickle as pkl
13 |
14 |
15 | # 生成lsi特征(潜在语义索引)
16 | def gensim_Corpus(corpus=None):
17 | dictionary = corpora.Dictionary(corpus)
18 | # 转换成doc_bow
19 | doc_bow_corpus = [dictionary.doc2bow(doc_cut) for doc_cut in corpus]
20 | # print(doc_bow_corpus)
21 | # 生成tfidf特征
22 | tfidf_model = models.TfidfModel(dictionary=dictionary) # 生成tfidf模型
23 | tfidf_corpus = [tfidf_model[doc_bow] for doc_bow in doc_bow_corpus] # 将每doc_bow转换成对应的tfidf_doc向量
24 | print('TFIDF:\n',tfidf_corpus)
25 |
26 | lsi_model = models.LsiModel(corpus=tfidf_corpus, id2word=dictionary, num_topics=10) # 生成lsi model
27 | # 生成corpus of lsi
28 | lsi_corpus = [lsi_model[tfidf_doc] for tfidf_doc in tfidf_corpus] # 转换成lsi向量
29 | print('LSI:\n',lsi_corpus)
30 | # 将lsi模型存储到磁盘上
31 | savepath =r'../dataSet/files/lsi_model.pkl'
32 | lsi_file = open(savepath, 'wb')
33 | pkl.dump(lsi_model, lsi_file)
34 | lsi_file.close()
35 | print('--- lsi模型已经生成 ---')
36 |
37 | if __name__=='__main__':
38 | # corpus参数样例数据如下:
39 | corpus,classVec = loadDataSet()
40 | gensim_Corpus(corpus)
41 |
--------------------------------------------------------------------------------
/GensimVec/RP.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:RP 生成随机映射
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from mydict import *
10 | from gensim import corpora, models
11 | from gensim.models.doc2vec import Doc2Vec, TaggedDocument
12 | import pickle as pkl
13 |
14 |
15 |
16 | '''
17 | 随机映射(Random Projections,RP)
18 | 目的在于减小空维度。这是一个非常高效(对CPU和内存都很友好)方法,通过抛出一点点随机性,来近似得到两个文档之间的Tfidf距离。推荐目标维度也是成百上千,具体数值要视你的数据集大小而定。
19 |
20 | 优点:减小空维度、CPU和内存都很友好
21 | '''
22 |
23 |
24 | # 生成随机映射(Random Projections,RP)
25 | def gensim_Corpus(corpus=None):
26 | dictionary = corpora.Dictionary(corpus)
27 | # 1 doc_bow转化为tfidf向量
28 | doc_bow_corpus = [dictionary.doc2bow(doc_cut) for doc_cut in corpus]
29 | tfidf_model = models.TfidfModel(dictionary=dictionary) # 生成tfidf模型
30 | tfidf_corpus = [tfidf_model[doc_bow] for doc_bow in doc_bow_corpus]
31 | print('doc_bow转换成对应的tfidf_doc向量:\n',tfidf_corpus)
32 |
33 | # 2 生成corpus of RP
34 | rp_model = models.RpModel(tfidf_corpus, num_topics=20)
35 | rp_corpus = [rp_model[tfidf_doc] for tfidf_doc in tfidf_corpus] # 转换成随机映射tfidf向量
36 | print('RP:\n',rp_corpus)
37 |
38 | # 3 将RP模型存储到磁盘上
39 | savepath =r'../dataSet/files/rp_model.pkl'
40 | rp_file = open(savepath, 'wb')
41 | pkl.dump(rp_model, rp_file)
42 | rp_file.close()
43 | print('--- RP模型已经生成 ---')
44 |
45 | if __name__=='__main__':
46 | # corpus参数样例数据如下:
47 | corpus,classVec = loadDataSet()
48 | gensim_Corpus(corpus)
49 |
--------------------------------------------------------------------------------
/GensimVec/StopWords.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:自定义去停用词
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import re,jieba,sys
10 |
11 | # 加载自定义分词词典
12 | jieba.load_userdict("../dataSet/StopWord/user_dict.txt")
13 |
14 |
15 | #********************1 结巴中文分词***********************************
16 |
17 | # 利用jieba对文本进行分词,返回切词后的list
18 | def seg_doc(str_doc):
19 | # 1 正则处理原文本
20 | sent_list = str_doc.split('\n')
21 | # map内置高阶函数:一个函数f和list,函数f依次作用在list.
22 | sent_list = map(textParse, sent_list) # 正则处理,去掉一些字符,例如\u3000
23 |
24 | # 2 获取停用词
25 | stwlist = get_stop_words()
26 |
27 | # 3 分词并去除停用词
28 | word_2dlist = [rm_tokens(jieba.cut(part, cut_all=False),stwlist) for part in sent_list]
29 |
30 | # 4 合并列表
31 | word_list = sum(word_2dlist, [])
32 | return word_list
33 |
34 |
35 | # 正则对字符串清洗
36 | def textParse(str_doc):
37 | # 正则过滤掉特殊符号、标点、英文、数字等。
38 | # r1 = '[a-zA-Z0-9’!"#$%&\'()*+,-./::;;|<=>?@,—。?★、…【】《》?“”‘’![\\]^_`{|}~]+'
39 | # str_doc=re.sub(r1, ' ', str_doc)
40 |
41 | # 去掉字符
42 | str_doc = re.sub('\u3000', '', str_doc)
43 |
44 | # 去除空格
45 | # str_doc=re.sub('\s+', ' ', str_doc)
46 |
47 | # 去除换行符
48 | # str_doc = str_doc.replace('\n',' ')
49 | return str_doc
50 |
51 |
52 | # 创建停用词列表
53 | def get_stop_words(path=r'../dataSet/StopWord/NLPIR_stopwords.txt'):
54 | file = open(path, 'r',encoding='utf-8').read().split('\n')
55 | return set(file)
56 |
57 | # 去掉一些停用词和数字
58 | def rm_tokens(words,stwlist):
59 | words_list = list(words)
60 | stop_words = stwlist
61 | for i in range(words_list.__len__())[::-1]:
62 | if words_list[i] in stop_words: # 去除停用词
63 | words_list.pop(i)
64 | elif words_list[i].isdigit(): # 去除数字
65 | words_list.pop(i)
66 | elif len(words_list[i]) == 1: # 去除单个字符
67 | words_list.pop(i)
68 | elif words_list[i] == " ": # 去除空字符
69 | words_list.pop(i)
70 | return words_list
71 |
72 |
73 | # 读取文本信息
74 | def readFile(path):
75 | str_doc = ""
76 | with open(path,'r',encoding='utf-8') as f:
77 | str_doc = f.read()
78 | return str_doc
79 |
80 |
81 |
82 | if __name__=='__main__':
83 | # 1 读取文本
84 | path= r'../dataSet/CSCMNews/体育/0.txt'
85 | str_doc = readFile(path)
86 | # print(str_doc)
87 |
88 | # 2 分词去停用词
89 | word_list = seg_doc(str_doc)
90 | print(word_list)
--------------------------------------------------------------------------------
/GensimVec/TFIDF.py:
--------------------------------------------------------------------------------
1 |
2 | # coding:utf8
3 |
4 | """
5 | Description:gensim计算tfidf
6 | Author:伏草惟存
7 | Prompt: code in Python3 env
8 | """
9 |
10 | import os
11 | from mydict import *
12 | from gensim import corpora, models
13 |
14 |
15 | # tfidf特征
16 | def gensim_Corpus(corpus=None,classVec=''):
17 | dictionary = corpora.Dictionary(corpus)
18 |
19 | # 转换成doc_bow
20 | doc_bow_corpus = [dictionary.doc2bow(doc_cut) for doc_cut in corpus]
21 | print('词袋模型实现文本向量化:\n',doc_bow_corpus)
22 |
23 | # 生成tfidf特征
24 | tfidf_model = models.TfidfModel(dictionary=dictionary)
25 | print('生成tfidf模型 :\n',tfidf_model) #num_nnz是每个文件中不重复词个数的和
26 |
27 | corpus_tfidf = {} # tfidf字典
28 | i=0 # 获取类别
29 | for doc_bow in doc_bow_corpus:
30 | file_tfidf = tfidf_model[doc_bow] # 词袋填充
31 | catg = classVec[i] # 类别
32 | tmp = corpus_tfidf.get(catg, [])
33 | tmp.append(file_tfidf)
34 | print('第',i,'类下特征词的TFIDF:\n',tmp)
35 | if tmp.__len__() == 1: # 某篇文章成功
36 | corpus_tfidf[catg] = tmp
37 | i+=1
38 | # 本地化存储
39 | print('tfidf字典:\n',corpus_tfidf)
40 | catgs = list(corpus_tfidf.keys())
41 | for catg in catgs:
42 | savepath =r'../dataSet/files/tfidf_corpus'
43 | corpora.MmCorpus.serialize('{f}{s}{c}.mm'.format(f=savepath, s=os.sep, c=catg),corpus_tfidf.get(catg),id2word=dictionary)
44 |
45 |
46 |
47 | if __name__=='__main__':
48 | # corpus参数样例数据如下:
49 | corpus,classVec = loadDataSet()
50 | gensim_Corpus(corpus,classVec)
51 |
--------------------------------------------------------------------------------
/GensimVec/__pycache__/StopWords.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/GensimVec/__pycache__/StopWords.cpython-35.pyc
--------------------------------------------------------------------------------
/GensimVec/__pycache__/StopWords.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/GensimVec/__pycache__/StopWords.cpython-37.pyc
--------------------------------------------------------------------------------
/GensimVec/__pycache__/mydict.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/GensimVec/__pycache__/mydict.cpython-35.pyc
--------------------------------------------------------------------------------
/GensimVec/__pycache__/mydict.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/GensimVec/__pycache__/mydict.cpython-37.pyc
--------------------------------------------------------------------------------
/GensimVec/freqword.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:gensim进行特征词提取
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from mydict import *
10 | from gensim import corpora
11 |
12 |
13 | # 2 统计词频特征
14 | def gensim_Corpus(corpus=None):
15 | dictionary = corpora.Dictionary(corpus)
16 | dfs = dictionary.dfs # 词频词典
17 | for key_id, c in dfs.items():
18 | print(dictionary[key_id], c)
19 | return dictionary[key_id], c
20 |
21 |
22 |
23 | if __name__=='__main__':
24 | # corpus参数样例数据如下:
25 | corpus,classVec = loadDataSet()
26 | gensim_Corpus(corpus)
27 |
--------------------------------------------------------------------------------
/GensimVec/mydict.py:
--------------------------------------------------------------------------------
1 |
2 | # coding:utf8
3 |
4 | """
5 | Description:gensim包进行特征词提取
6 | Author:伏草惟存
7 | Prompt: code in Python3 env
8 | """
9 |
10 | from gensim import corpora
11 |
12 |
13 | # 构建语料词典
14 | def gensim_Corpus(corpus=None):
15 | # 1 词典
16 | dictionary = corpora.Dictionary(corpus)
17 | print('构造语料词典:\n',dictionary)
18 |
19 | # 2 删除停用词和仅出现一次的词
20 | # once_ids = [dictionary[tokenid] for tokenid, docfreq in dictionary.dfs.items() if docfreq == 1]
21 | once_ids = [tokenid for tokenid, docfreq in dictionary.dfs.items() if docfreq == 1]
22 | print('仅出现一次的词:\n',once_ids)
23 | dictionary.filter_tokens(once_ids)
24 | print('自定义选择后的特征词典:\n',dictionary)
25 | # 消除id序列在删除词后产生的不连续的缺口
26 | dictionary.compactify()
27 |
28 | # 3 dict 方式存储词典
29 | savePath = r'../dataSet/files/mycorpus.dict'
30 | dictionary.save(savePath) # 把字典保存起来,方便以后使用
31 |
32 | mydict = corpora.Dictionary.load(savePath)
33 | print('加载Dict词典:\n',mydict)
34 |
35 | # 4 Txt 方式存储词典
36 | savePath = r'../dataSet/files/mycorpus.txt'
37 | dictionary.save_as_text(savePath) # 保存文本
38 |
39 | list2 = corpora.Dictionary.load_from_text(savePath) # 加载文本
40 | print('加载txt词典:\n',list2)
41 |
42 |
43 |
44 | '''创建数据集:单词列表postingList, 所属类别classVec'''
45 | def loadDataSet():
46 | # corpus参数样例数据如下:
47 | corpus =[]
48 | tiyu = ['姚明', '我来', '承担', '连败', '巨人', '宣言', '酷似', '当年', '麦蒂', '新浪', '体育讯', '北京', '时间', '消息', '休斯敦', '纪事报', '专栏', '记者', '乔纳森', '费根', '报道', '姚明', '渴望', '一场', '胜利', '当年', '队友', '麦蒂', '惯用', '句式']
49 | yule = ['谢婷婷', '模特', '酬劳', '仅够', '生活', '风光', '背后', '惨遭', '拖薪', '新浪', '娱乐', '金融', '海啸', 'blog', '席卷', '全球', '模特儿', '酬劳', '被迫', '打折', '全职', 'Model', '谢婷婷', '业界', '工作量', '有增无减', '收入', '仅够', '糊口', '拖薪']
50 | jioayu = ['名师', '解读', '四六级', '阅读', '真题', '技巧', '考前', '复习', '重点', '历年', '真题', '阅读', '听力', '完形', '提升', '空间', '天中', '题为', '主导', '考过', '六级', '四级', '题为', '主导', '真题', '告诉', '方向', '会考', '题材', '包括']
51 | shizheng = ['美国', '军舰', '抵达', '越南', '联合', '军演', '中新社', '北京', '日电', '杨刚', '美国', '海军', '第七', '舰队', '三艘', '军舰', '抵达', '越南', '岘港', '为期', '七天', '美越', '南海', '联合', '军事训练', '拉开序幕', '美国', '海军', '官方网站', '消息']
52 |
53 | corpus.append(tiyu)
54 | corpus.append(yule)
55 | corpus.append(jioayu)
56 | corpus.append(shizheng)
57 |
58 | classVec = ['体育','娱乐','教育','时政']
59 | return corpus,classVec
60 |
61 |
62 |
63 | if __name__=='__main__':
64 | # corpus参数样例数据如下:
65 | corpus,classVec = loadDataSet()
66 | gensim_Corpus(corpus)
67 |
--------------------------------------------------------------------------------
/PCADim/Visual.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | from numpy import *
4 | from pca import *
5 | import matplotlib
6 | import matplotlib.pyplot as plt
7 |
8 | '''
9 | Description:PCA降维后的数据可视化显示
10 | Author:伏草惟存
11 | Prompt: code in Python3 env
12 | '''
13 |
14 |
15 | '''降维后的数据和原始数据可视化'''
16 | def show_picture(dataMat, reconMat):
17 | fig = plt.figure()
18 | ax = fig.add_subplot(111)
19 | # flatten()方法能将matrix的元素变成一维的,A能使matrix变成array,A[0]或者数组数据
20 | ax.scatter(dataMat[:, 0].flatten().A[0], dataMat[:, 1].flatten().A[0], marker='^', s=90,c='green')
21 | ax.scatter(reconMat[:, 0].flatten().A[0], reconMat[:, 1].flatten().A[0], marker='o', s=50, c='red')
22 | plt.show()
23 |
24 |
25 |
26 |
27 |
28 |
29 | if __name__ == "__main__":
30 | # 1 加载数据,并转化数据类型为float
31 | dataMat = loadDataSet('./testSet.txt')
32 | # print('加载原始特征数据:\n',dataMat)
33 |
34 | # 2 主成分分析降维特征向量设置
35 | lowDmat, reconMat = pca(dataMat,1)
36 | # print(shape(lowDmat))
37 | # 只需要2个特征向量,和原始数据一致,没任何变化
38 | # lowDmat, reconMat = pca(dataMat, 2)
39 | # print(shape(lowDmat))
40 |
41 | # 3 将降维后的数据和原始数据一起可视化
42 | show_picture(dataMat, reconMat)
43 |
44 |
--------------------------------------------------------------------------------
/PCADim/__pycache__/loadData.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/PCADim/__pycache__/loadData.cpython-37.pyc
--------------------------------------------------------------------------------
/PCADim/__pycache__/loadnews.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/PCADim/__pycache__/loadnews.cpython-37.pyc
--------------------------------------------------------------------------------
/PCADim/__pycache__/pca.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/PCADim/__pycache__/pca.cpython-37.pyc
--------------------------------------------------------------------------------
/PCADim/allpca.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | import numpy
4 | from numpy import *
5 | import matplotlib
6 | import matplotlib.pyplot as plt
7 |
8 | '''一步步教你轻松学主成分分析PCA降维算法
9 | Blog:https://bainingchao.github.io/
10 | Date:2018年9月29日11:18:08
11 | '''
12 |
13 | '''加载数据集'''
14 | def loadDataSet(fileName, delim='\t'):
15 | fr = open(fileName)
16 | stringArr = [line.strip().split(delim) for line in fr.readlines()]
17 | datArr = [list(map(float, line)) for line in stringArr]
18 | #注意这里和python2的区别,需要在map函数外加一个list(),否则显示结果为 map at 0x3fed1d0
19 | return mat(datArr)
20 |
21 |
22 | '''pca算法
23 | 方差:(一维)度量两个随机变量关系的统计量,数据离散程度,方差越小越稳定
24 | 协方差: (二维)度量各个维度偏离其均值的程度
25 | 协方差矩阵:(多维)度量各个维度偏离其均值的程度
26 |
27 | 当 cov(X, Y)>0时,表明X与Y正相关(X越大,Y也越大;X越小Y,也越小。)
28 | 当 cov(X, Y)<0时,表明X与Y负相关;
29 | 当 cov(X, Y)=0时,表明X与Y不相关。
30 |
31 | cov协方差=[(x1-x均值)*(y1-y均值)+(x2-x均值)*(y2-y均值)+...+(xn-x均值)*(yn-y均值)]/(n-1)
32 | Args:
33 | dataMat 原数据集矩阵
34 | topNfeat 应用的N个特征
35 | Returns:
36 | lowDDataMat 降维后数据集
37 | reconMat 新的数据集空间
38 |
39 | 1 去除平均值
40 | 2 计算协方差矩阵
41 | 3 计算协方差矩阵的特征值和特征向量
42 | 4 将特征值排序
43 | 5 保留前N个最大的特征值对应的特征向量
44 | 6 将数据转换到上面得到的N个特征向量构建的新空间中(实现了特征压缩)
45 | '''
46 | def pca(dataMat, topNfeat=9999999):
47 | # 1 计算每一列的均值
48 | meanVals = mean(dataMat, axis=0) # axis=0表示列,axis=1表示行
49 | print('各列的均值:\n', meanVals)
50 |
51 | # 2 去平均值,每个向量同时都减去均值
52 | meanRemoved = dataMat - meanVals
53 | print('每个向量同时都减去均值:\n', meanRemoved)
54 |
55 | # 3 计算协方差矩阵的特征值与特征向量,eigVals为特征值, eigVects为
56 | # rowvar=0,传入的数据一行代表一个样本,若非0,传入的数据一列代表一个样本
57 | covMat = cov(meanRemoved, rowvar=0)
58 | eigVals, eigVects = linalg.eig(mat(covMat))
59 | print('特征值:\n', eigVals,'\n特征向量:\n', eigVects)
60 |
61 | # 4 将特征值排序, 特征值的逆序就可以得到topNfeat个最大的特征向量
62 | eigValInd = argsort(eigVals) # 特征值从小到大的排序,返回从小到大的index序号
63 | # print('eigValInd1=', eigValInd)
64 |
65 | # 5 保留前N个特征。-1表示倒序,返回topN的特征值[-1到-(topNfeat+1)不包括-(topNfeat+1)]
66 | eigValInd = eigValInd[:-(topNfeat+1):-1]
67 | # 重组 eigVects 最大到最小
68 | redEigVects = eigVects[:, eigValInd]
69 | print('重组n特征向量最大到最小:\n', redEigVects.T)
70 |
71 | # 6 将数据转换到新空间
72 | # print( "---", shape(meanRemoved), shape(redEigVects))
73 | lowDDataMat = meanRemoved * redEigVects
74 | reconMat = (lowDDataMat * redEigVects.T) + meanVals
75 | # print('lowDDataMat=', lowDDataMat)
76 | # print('reconMat=', reconMat)
77 | return lowDDataMat, reconMat
78 |
79 |
80 |
81 | '''降维后的数据和原始数据可视化'''
82 | def show_picture(dataMat, reconMat):
83 | fig = plt.figure()
84 | ax = fig.add_subplot(111)
85 | ax.scatter(dataMat[:, 0].flatten().A[0], dataMat[:, 1].flatten().A[0], marker='^', s=90,c='green')
86 | ax.scatter(reconMat[:, 0].flatten().A[0], reconMat[:, 1].flatten().A[0], marker='o', s=50, c='red')
87 | plt.show()
88 |
89 |
90 |
91 | '''将NaN替换成平均值函数
92 | secom.data 为1567篇文章,每篇文章590个单词
93 | '''
94 | def replaceNanWithMean():
95 | datMat = loadDataSet('./secom.data', ' ')
96 | numFeat = shape(datMat)[1]
97 | for i in range(numFeat):
98 | # 对value不为NaN的求均值
99 | # .A 返回矩阵基于的数组
100 | meanVal = mean(datMat[nonzero(~isnan(datMat[:, i].A))[0], i])
101 | # 将value为NaN的值赋值为均值
102 | datMat[nonzero(isnan(datMat[:, i].A))[0],i] = meanVal
103 | return datMat
104 |
105 |
106 |
107 | '''分析数据'''
108 | def analyse_data(dataMat,topNfeat = 20):
109 | meanVals = mean(dataMat, axis=0)
110 | meanRemoved = dataMat-meanVals
111 | covMat = cov(meanRemoved, rowvar=0)
112 | eigvals, eigVects = linalg.eig(mat(covMat))
113 | eigValInd = argsort(eigvals)
114 |
115 |
116 | eigValInd = eigValInd[:-(topNfeat+1):-1]
117 | cov_all_score = float(sum(eigvals))
118 | sum_cov_score = 0
119 | for i in range(0, len(eigValInd)):
120 | line_cov_score = float(eigvals[eigValInd[i]])
121 | sum_cov_score += line_cov_score
122 | '''
123 | 我们发现其中有超过20%的特征值都是0。
124 | 这就意味着这些特征都是其他特征的副本,也就是说,它们可以通过其他特征来表示,而本身并没有提供额外的信息。
125 |
126 | 最前面15个值的数量级大于10^5,实际上那以后的值都变得非常小。
127 | 这就相当于告诉我们只有部分重要特征,重要特征的数目也很快就会下降。
128 |
129 | 最后,我们可能会注意到有一些小的负值,他们主要源自数值误差应该四舍五入成0.
130 | '''
131 | print('主成分:%s, 方差占比:%s%%, 累积方差占比:%s%%' % (format(i+1, '2.0f'), format(line_cov_score/cov_all_score*100, '4.2f'), format(sum_cov_score/cov_all_score*100, '4.1f')))
132 |
133 |
134 | if __name__ == "__main__":
135 | # 1 加载数据,并转化数据类型为float
136 | # dataMat = loadDataSet('./testSet.txt')
137 | # print('加载原始特征数据:\n',dataMat)
138 |
139 | # 2 主成分分析降维特征向量设置
140 | # lowDmat, reconMat = pca(dataMat,1)
141 | # print(shape(lowDmat))
142 | # 只需要2个特征向量,和原始数据一致,没任何变化
143 | # lowDmat, reconMat = pca(dataMat, 2)
144 | # print(shape(lowDmat))
145 |
146 | # 3 将降维后的数据和原始数据一起可视化
147 | # show_picture(dataMat, reconMat)
148 |
149 | # 4 利用PCA对新闻数据降维
150 | dataMat = replaceNanWithMean()
151 | print(shape(dataMat))
152 | # 分析数据
153 | # analyse_data(dataMat,20)
154 | lowDmat, reconMat = pca(dataMat,20)
155 | print(shape(lowDmat)) # 1567篇文章,提取前20个单词
156 | show_picture(dataMat, reconMat)
157 |
--------------------------------------------------------------------------------
/PCADim/analyse.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | from numpy import *
4 | from loadnews import *
5 |
6 | '''
7 | Description:分析新闻数据主成分特征
8 | Author:伏草惟存
9 | Prompt: code in Python3 env
10 | '''
11 |
12 | '''分析数据'''
13 | def analyse_data(dataMat,topNfeat = 20):
14 | # 去除平均值
15 | meanVals = mean(dataMat, axis=0)
16 | meanRemoved = dataMat-meanVals
17 | # 计算协方差矩阵
18 | covMat = cov(meanRemoved, rowvar=0)
19 | # 特征值和特征向量
20 | eigvals, eigVects = linalg.eig(mat(covMat))
21 | eigValInd = argsort(eigvals)
22 | # 保留前N个特征
23 | eigValInd = eigValInd[:-(topNfeat+1):-1]
24 | # 对特征主成分分析
25 | cov_all_score = float(sum(eigvals))
26 | sum_cov_score = 0
27 | for i in range(0, len(eigValInd)):
28 | line_cov_score = float(eigvals[eigValInd[i]])
29 | sum_cov_score += line_cov_score
30 | '''
31 | 我们发现其中有超过20%的特征值都是0。
32 | 这就意味着这些特征都是其他特征的副本,也就是说,它们可以通过其他特征来表示,而本身并没有提供额外的信息。
33 |
34 | 最前面15个值的数量级大于10^5,实际上那以后的值都变得非常小。
35 | 这就相当于告诉我们只有部分重要特征,重要特征的数目也很快就会下降。
36 |
37 | 最后,我们可能会注意到有一些小的负值,他们主要源自数值误差应该四舍五入成0.
38 | '''
39 | print('主成分:%s, 方差占比:%s%%, 累积方差占比:%s%%' % (format(i+1, '2.0f'), format(line_cov_score/cov_all_score*100, '4.2f'), format(sum_cov_score/cov_all_score*100, '4.1f')))
40 |
41 |
42 |
43 |
44 | if __name__ == "__main__":
45 | # 加载新闻数据
46 | dataMat = replaceNanWithMean()
47 | # print(shape(dataMat))
48 | # 分析数据:要求满足99%即可
49 | line_cov_score=analyse_data(dataMat,17)
50 |
--------------------------------------------------------------------------------
/PCADim/loadData.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | from numpy import *
4 |
5 | '''
6 | Description:加载坐标系数据
7 | Author:伏草惟存
8 | Prompt: code in Python3 env
9 | '''
10 |
11 | '''加载数据集'''
12 | def loadDataSet(fileName, delim='\t'):
13 | fr = open(fileName)
14 | stringArr = [line.strip().split(delim) for line in fr.readlines()]
15 | datArr = [list(map(float, line)) for line in stringArr]
16 | #注意这里和python2的区别,需要在map函数外加一个list(),否则显示结果为 map at 0x3fed1d0
17 | return mat(datArr)
18 |
19 |
20 |
21 |
22 |
23 | if __name__ == "__main__":
24 | # 1 加载数据,并转化数据类型为float
25 | dataMat = loadDataSet('./testSet.txt')
26 | print('坐标系原始数据:\n',dataMat)
27 |
28 |
--------------------------------------------------------------------------------
/PCADim/loadnews.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | from numpy import *
4 | from loadData import *
5 |
6 | '''
7 | Description:处理带有缺少值的新闻数据
8 | Author:伏草惟存
9 | Prompt: code in Python3 env
10 | '''
11 |
12 |
13 |
14 | '''将NaN替换成平均值函数
15 | secom.data 为1567篇文章,每篇文章590个单词
16 | '''
17 | def replaceNanWithMean():
18 | datMat = loadDataSet('./secom.data', ' ')
19 | # print('缺少值的新闻数据:\n',datMat)
20 | numFeat = shape(datMat)[1]
21 | for i in range(numFeat):
22 | # 对value不为NaN的求均值
23 | # .A 返回矩阵基于的数组
24 | meanVal = mean(datMat[nonzero(~isnan(datMat[:, i].A))[0], i])
25 | # 将value为NaN的值赋值为均值
26 | datMat[nonzero(isnan(datMat[:, i].A))[0],i] = meanVal
27 | return datMat
28 |
29 |
30 |
31 | if __name__ == "__main__":
32 | # 加载新闻数据
33 | dataMat = replaceNanWithMean()
34 | print('处理缺少值的新闻数据:\n',dataMat)
35 | print('新闻矩阵数据规模:\n',shape(dataMat))
36 |
37 |
--------------------------------------------------------------------------------
/PCADim/pca.md:
--------------------------------------------------------------------------------
1 | PCA 概述
2 |
3 | 什么是数据降维?
4 | 降维是对数据高维度特征的一种预处理方法。降维是将高维度的数据保留下最重要的一些特征,去除噪声和不重要的特征,从而实现提升数据处理速度的目的。在实际的生产和应用中,降维在一定的信息损失范围内,可以为我们节省大量的时间和成本。降维也成为了应用非常广泛的数据预处理方法。
5 |
6 | 数据降维的目的?
7 | 使得数据集更容易使用
8 | 确保这些变量是相互独立的
9 | 降低很多算法的计算开销
10 | 去除噪音
11 | 使得结果易懂
12 |
13 | 什么是PCA降维?
14 | 主成分分析(英语:Principal components analysis,PCA)是一种分析、简化数据集的技术。主成分分析经常用于减少数据集的维数,同时保持数据集中的对方差贡献最大的特征。通俗理解就是找出最主要的特征,然后进行分析。
15 | 主成分分析由卡尔·皮尔逊于1901年发明,用于分析数据及建立数理模型。其方法主要是通过对协方差矩阵进行特征分解,以得出数据的主成分(即特征向量)与它们的权值(即特征值)。
16 |
17 | 案例分析?
18 | 例如: 考察一个人的智力情况,就直接看数学成绩就行(存在:数学、语文、英语成绩)
19 |
20 | PCA实现原理?
21 | 找出第一个主成分的方向,也就是数据方差最大的方向。
22 | 找出第二个主成分的方向,也就是数据方差次大的方向,并且该方向与第一个主成分方向正交。
23 | 通过这种方式计算出所有的主成分方向。
24 | 通过数据集的协方差矩阵及其特征值分析,我们就可以得到这些主成分的值。
25 | 一旦得到了协方差矩阵的特征值和特征向量,我们就可以保留最大的 N 个特征。这些特征向量也给出了 N 个最重要特征的真实结构,我们就可以通过将数据乘上这 N 个特征向量 从而将它转换到新的空间上。
26 |
27 | PCA实现步骤?
28 | 去除平均值
29 | 计算协方差矩阵
30 | 计算协方差矩阵的特征值和特征向量
31 | 将特征值排序
32 | 保留前N个最大的特征值对应的特征向量
33 | 将数据转换到上面得到的N个特征向量构建的新空间中(实现了特征压缩)
34 |
35 | PCA 优缺点?
36 | 优点:降低数据的复杂性,识别最重要的多个特征。
37 | 缺点:不一定需要,且可能损失有用信息。
--------------------------------------------------------------------------------
/PCADim/pca.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | from numpy import *
4 | from loadData import *
5 |
6 | '''
7 | Description:PCA算法实现
8 | Author:伏草惟存
9 | Prompt: code in Python3 env
10 | '''
11 |
12 | '''加载数据集'''
13 | def loadDataSet(fileName, delim='\t'):
14 | fr = open(fileName)
15 | stringArr = [line.strip().split(delim) for line in fr.readlines()]
16 | datArr = [list(map(float, line)) for line in stringArr]
17 | #注意这里和python2的区别,需要在map函数外加一个list(),否则显示结果为 map at 0x3fed1d0
18 | return mat(datArr)
19 |
20 |
21 | '''pca算法
22 | 方差:(一维)度量两个随机变量关系的统计量,数据离散程度,方差越小越稳定
23 | 协方差: (二维)度量各个维度偏离其均值的程度
24 | 协方差矩阵:(多维)度量各个维度偏离其均值的程度
25 |
26 | 当 cov(X, Y)>0时,表明X与Y正相关(X越大,Y也越大;X越小Y,也越小。)
27 | 当 cov(X, Y)<0时,表明X与Y负相关;
28 | 当 cov(X, Y)=0时,表明X与Y不相关。
29 |
30 | cov协方差=[(x1-x均值)*(y1-y均值)+(x2-x均值)*(y2-y均值)+...+(xn-x均值)*(yn-y均值)]/(n-1)
31 | Args:
32 | dataMat 原数据集矩阵
33 | topNfeat 应用的N个特征
34 | Returns:
35 | lowDDataMat 降维后数据集
36 | reconMat 新的数据集空间
37 |
38 | 1 去除平均值
39 | 2 计算协方差矩阵
40 | 3 计算协方差矩阵的特征值和特征向量
41 | 4 将特征值排序
42 | 5 保留前N个最大的特征值对应的特征向量
43 | 6 将数据转换到上面得到的N个特征向量构建的新空间中(实现了特征压缩)
44 | '''
45 | def pca(dataMat, topNfeat=9999999):
46 | # 1 计算每一列的均值
47 | meanVals = mean(dataMat, axis=0) # axis=0表示列,axis=1表示行
48 | print('各列的均值:\n', meanVals)
49 |
50 | # 2 去平均值,每个向量同时都减去均值
51 | meanRemoved = dataMat - meanVals
52 | print('每个向量同时都减去均值:\n', meanRemoved)
53 |
54 | # 3 计算协方差矩阵的特征值与特征向量,eigVals为特征值, eigVects为
55 | # rowvar=0,传入的数据一行代表一个样本,若非0,传入的数据一列代表一个样本
56 | covMat = cov(meanRemoved, rowvar=0)
57 | eigVals, eigVects = linalg.eig(mat(covMat))
58 | print('特征值:\n', eigVals,'\n特征向量:\n', eigVects)
59 |
60 | # 4 将特征值排序, 特征值的逆序就可以得到topNfeat个最大的特征向量
61 | eigValInd = argsort(eigVals) # 特征值从小到大的排序,返回从小到大的index序号
62 | # print('eigValInd1=', eigValInd)
63 |
64 | # 5 保留前N个特征。-1表示倒序,返回topN的特征值[-1到-(topNfeat+1)不包括-(topNfeat+1)]
65 | eigValInd = eigValInd[:-(topNfeat+1):-1]
66 | # 重组 eigVects 最大到最小
67 | redEigVects = eigVects[:, eigValInd]
68 | print('重组n特征向量最大到最小:\n', redEigVects.T)
69 |
70 | # 6 将数据转换到新空间
71 | # print( "---", shape(meanRemoved), shape(redEigVects))
72 | lowDDataMat = meanRemoved * redEigVects
73 | reconMat = (lowDDataMat * redEigVects.T) + meanVals
74 | # print('lowDDataMat=', lowDDataMat)
75 | # print('reconMat=', reconMat)
76 | return lowDDataMat, reconMat
77 |
78 |
79 |
80 |
81 | if __name__ == "__main__":
82 | # 1 加载数据,并转化数据类型为float
83 | dataMat = loadDataSet('./testSet.txt')
84 | print('加载原始特征数据:\n',dataMat)
85 |
86 | # 2 主成分分析降维特征向量设置
87 | lowDmat, reconMat = pca(dataMat,1)
88 | print(shape(lowDmat))
89 | # 只需要2个特征向量,和原始数据一致,没任何变化
90 | # lowDmat, reconMat = pca(dataMat, 2)
91 | # print(shape(lowDmat))
92 |
93 |
--------------------------------------------------------------------------------
/PCADim/pcanews.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | from numpy import *
4 | import matplotlib
5 | import matplotlib.pyplot as plt
6 |
7 | '''
8 | Description:PCA新闻数据降维并可视化分析
9 | Author:伏草惟存
10 | Prompt: code in Python3 env
11 | '''
12 |
13 | '''加载数据集'''
14 | def loadDataSet(fileName, delim='\t'):
15 | fr = open(fileName)
16 | stringArr = [line.strip().split(delim) for line in fr.readlines()]
17 | datArr = [list(map(float, line)) for line in stringArr]
18 | return mat(datArr)
19 |
20 |
21 | # 将NaN替换成平均值函数:secom.data 为1567篇文章,每篇文章590个单词
22 | def replaceNanWithMean():
23 | datMat = loadDataSet('./secom.data', ' ')
24 | numFeat = shape(datMat)[1]
25 | for i in range(numFeat):
26 | meanVal = mean(datMat[nonzero(~isnan(datMat[:, i].A))[0], i])
27 | datMat[nonzero(isnan(datMat[:, i].A))[0],i] = meanVal
28 | return datMat
29 |
30 |
31 | # 主成分降维
32 | def pca(dataMat, topNfeat=9999999):
33 | # 1 计算每一列的均值
34 | meanVals = mean(dataMat, axis=0) # axis=0表示列,axis=1表示行
35 |
36 | # 2 去平均值,每个向量同时都减去均值
37 | meanRemoved = dataMat - meanVals
38 |
39 | # 3 计算协方差矩阵的特征值与特征向量
40 | covMat = cov(meanRemoved, rowvar=0)
41 | eigVals, eigVects = linalg.eig(mat(covMat))
42 | print('特征值:\n', eigVals,'\n特征向量:\n', eigVects) # 很多特征值为0
43 |
44 | # 4 将特征值排序
45 | eigValInd = argsort(eigVals)
46 |
47 | # 5 保留前N个特征
48 | eigValInd = eigValInd[:-(topNfeat+1):-1]
49 | redEigVects = eigVects[:, eigValInd]
50 | # print('重组n特征向量最大到最小:\n', redEigVects.T)
51 |
52 | # 6 将数据转换到新空间
53 | lowDDataMat = meanRemoved * redEigVects
54 | reconMat = (lowDDataMat * redEigVects.T) + meanVals
55 | return lowDDataMat, reconMat
56 |
57 |
58 |
59 |
60 | '''降维后的数据和原始数据可视化'''
61 | def show_picture(dataMat, reconMat):
62 | fig = plt.figure()
63 | ax = fig.add_subplot(111)
64 | ax.scatter(dataMat[:, 0].flatten().A[0], dataMat[:, 1].flatten().A[0], marker='^', s=5,c='green')
65 | ax.scatter(reconMat[:, 0].flatten().A[0], reconMat[:, 1].flatten().A[0], marker='o', s=5, c='red')
66 | plt.show()
67 |
68 |
69 |
70 |
71 | if __name__ == "__main__":
72 | dataMat = replaceNanWithMean()
73 | # 分析数据
74 | lowDmat, reconMat = pca(dataMat,17)
75 | print(shape(lowDmat)) # 1567篇文章,提取前20个单词
76 | show_picture(dataMat, reconMat)
77 |
--------------------------------------------------------------------------------
/ProcessText/30wDealText.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:30万条新闻文本数据清洗
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import os,re,time,jieba
10 |
11 |
12 | class loadFolders(object): # 迭代器
13 | def __init__(self, par_path):
14 | self.par_path = par_path
15 | def __iter__(self):
16 | for file in os.listdir(self.par_path):
17 | file_abspath = os.path.join(self.par_path, file)
18 | if os.path.isdir(file_abspath): # if file is a folder
19 | yield file_abspath
20 |
21 | class loadFiles(object):
22 | def __init__(self, par_path):
23 | self.par_path = par_path
24 | def __iter__(self):
25 | folders = loadFolders(self.par_path)
26 | for folder in folders: # level directory
27 | catg = folder.split(os.sep)[-1]
28 | for file in os.listdir(folder): # secondary directory
29 | file_path = os.path.join(folder, file)
30 | if os.path.isfile(file_path):
31 | this_file = open(file_path, 'rb') #rb读取方式更快
32 | content = this_file.read().decode('utf8')
33 | yield catg, content
34 | this_file.close()
35 |
36 |
37 | # 利用jieba对文本进行分词,返回切词后的list
38 | def seg_doc(str_doc):
39 | sent_list = str_doc.split('\n')
40 | # 1 正则处理,去掉一些字符,例如\u3000
41 | sent_list = map(textParse, sent_list)
42 | # 2 获取停用词
43 | stwlist = get_stop_words()
44 | # 3 分词并去除停用词
45 | word_2dlist = [rm_tokens(jieba.cut(part, cut_all=False),stwlist) for part in sent_list]
46 | # 4 合并列表
47 | word_list = sum(word_2dlist, [])
48 | return word_list
49 |
50 |
51 | # 正则对字符串清洗
52 | def textParse(str_doc):
53 | # 去掉字符
54 | str_doc = re.sub('\u3000', '', str_doc)
55 | return str_doc
56 |
57 |
58 | # 创建停用词列表
59 | def get_stop_words(path=r'../dataSet/StopWord/NLPIR_stopwords.txt'):
60 | file = open(path, 'r',encoding='utf-8').read().split('\n')
61 | return set(file)
62 |
63 |
64 | # 去掉一些停用词和数字
65 | def rm_tokens(words,stwlist):
66 | words_list = list(words)
67 | stop_words = stwlist
68 | for i in range(words_list.__len__())[::-1]:
69 | if words_list[i] in stop_words: # 去除停用词
70 | words_list.pop(i)
71 | elif words_list[i].isdigit(): # 去除数字
72 | words_list.pop(i)
73 | elif len(words_list[i]) == 1: # 去除单个字符
74 | words_list.pop(i)
75 | elif words_list[i] == " ": # 去除空字符
76 | words_list.pop(i)
77 | return words_list
78 |
79 |
80 | # 读取文本信息
81 | def readFile(path):
82 | str_doc = ""
83 | with open(path,'r',encoding='utf-8') as f:
84 | str_doc = f.read()
85 | return str_doc
86 |
87 |
88 |
89 |
90 | if __name__=='__main__':
91 | start = time.time()
92 |
93 | filepath = os.path.abspath(r'../dataSet/CSCMNews')
94 | files = loadFiles(filepath)
95 | n = 3 # n 表示抽样率, n抽1
96 | for i, msg in enumerate(files):
97 | if i % n == 0:
98 | catg = msg[0]
99 | file = msg[1]
100 | file = seg_doc(file)
101 | if int(i/n) % 1000 == 0:
102 | print('{t} *** {i} \t docs has been dealed'
103 | .format(i=i, t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())),'\n',catg,':\t',file[:30])
104 |
105 | end = time.time()
106 | print('total spent times:%.2f' % (end-start)+ ' s')
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/ProcessText/FeatureWord.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:自定义提前特征词:人名、地名、机构名等
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import jieba.posseg as ps
10 |
11 | # 不同业务场景:评论情感判断,可以自定义特征抽取规则.
12 | def extract_feature_words(str_doc):
13 | featWord =""
14 | stwlist = get_stop_words()
15 | user_pos_list = [ 'nr', 'ns','nt','nz'] # 用户自定义特征词性列表
16 | for word, pos in ps.cut(str_doc):
17 | # 过滤掉停用词
18 | if word not in stwlist and pos in user_pos_list:
19 | if word+' '+pos+'\n' not in featWord:
20 | featWord += word+' '+pos+'\n'
21 | print(featWord)
22 |
23 |
24 | # 创建停用词列表
25 | def get_stop_words(path=r'../dataSet/StopWord/NLPIR_stopwords.txt'):
26 | file = open(path, 'r',encoding='utf-8').read().split('\n')
27 | return set(file)
28 |
29 |
30 | # 读取文本信息
31 | def readFile(path):
32 | str_doc = ""
33 | with open(path,'r',encoding='utf-8') as f:
34 | str_doc = f.read()
35 | return str_doc
36 |
37 |
38 | if __name__=='__main__':
39 | # 1 读取文本
40 | path= r'../dataSet/CSCMNews/体育/0.txt'
41 | str_doc = readFile(path)
42 |
43 | # 2 分词去停用词
44 | extract_feature_words(str_doc)
--------------------------------------------------------------------------------
/ProcessText/FreqWord.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:NLTK词频统计
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from nltk import *
10 | from StopWords import readFile,seg_doc
11 |
12 |
13 | #解决中文显示
14 | import matplotlib
15 | # (1)查看当前使用字体格式
16 | # from matplotlib.font_manager import findfont, FontProperties
17 | # print(findfont(FontProperties(family=FontProperties().get_family())))
18 | # (2)在C:\Windows\Fonts查找中文字体SimHei.ttf,并将其复制到../mpl-data/font/ttf文件夹下面
19 | # (3) 设置使用字体
20 | matplotlib.rcParams['font.sans-serif'] = 'SimHei'
21 |
22 |
23 | # 利用nltk进行词频特征统计
24 | def nltk_wf_feature(word_list=None):
25 | # ********统计词频方法1**************
26 | fdist=FreqDist(word_list)
27 | print(fdist.keys(),fdist.values())
28 |
29 | print('='*3,'指定词语词频统计','='*3)
30 | w='训练'
31 | print(w,'出现频率:',fdist.freq(w)) # 给定样本的频率
32 | print(w,'出现次数:',fdist[w]) # 出现次数
33 |
34 | print('='*3,'频率分布表','='*3)
35 | fdist.tabulate(30) # 频率分布表
36 |
37 | # print('='*3,'可视化词频','='*3)
38 | # fdist.plot(30) # 频率分布图
39 | # fdist.plot(30,cumulative=True) # 频率累计图
40 |
41 | # print('='*3,'根据词语长度查找词语','='*3)
42 | # wlist =[w for w in fdist if len(w)>2]
43 | # print(wlist)
44 |
45 |
46 | # ********统计词频方法2**************
47 | # from collections import Counter
48 | # Words = Counter(word_list)
49 | # print(Words.keys(),Words.values())
50 | # wlist =[w for w in Words if len(w)>2]
51 | # print(wlist)
52 |
53 | return fdist
54 |
55 |
56 |
57 | if __name__=='__main__':
58 | # 1 读取文本
59 | path= r'../dataSet/CSCMNews/体育/0.txt'
60 | str_doc = readFile(path)
61 | # print(str_doc)
62 |
63 | # 2 词频特征统计
64 | word_list =seg_doc(str_doc)
65 | fdist = nltk_wf_feature(word_list)
66 |
--------------------------------------------------------------------------------
/ProcessText/HLWord.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:自定义去高低词频
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from StopWords import readFile,seg_doc
10 | from FreqWord import *
11 |
12 |
13 | def freqword(fdist):
14 | wordlist =[]
15 | print('='*3,'打印统计的词频','='*3)
16 | for key in fdist.keys():
17 | if fdist.get(key)>2 and fdist.get(key)<15:
18 | wordlist.append(key+':'+str(fdist.get(key)))
19 | return wordlist
20 |
21 |
22 | if __name__=='__main__':
23 | # 1 读取文本
24 | path= r'../dataSet/CSCMNews/体育/0.txt'
25 | str_doc = readFile(path)
26 | word_list =seg_doc(str_doc)
27 | # 2 选择高低词
28 | fdist = nltk_wf_feature(word_list)
29 | wordlist=freqword(fdist)
30 | print(wordlist)
--------------------------------------------------------------------------------
/ProcessText/HanLPCut.py:
--------------------------------------------------------------------------------
1 | #coding=utf8
2 |
3 | """
4 | Description: hanlp分词操作详解
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | '''
10 | JPype is an effort to allow python programs full access to java class
11 | libraries
12 | pip install JPype1
13 | >pip install wheel
14 | >pip install JPype1-0.6.3-cp37-cp37m-win_amd64.whl
15 | '''
16 |
17 | from jpype import *
18 |
19 | # 调用HanLP的java包,如下路径下载并解压c盘即可:
20 | # 启动JVM,Linux需替换分号;为冒号:
21 | startJVM(getDefaultJVMPath(), "-Djava.class.path=C:\hanlp\hanlp-1.3.2.jar;C:\hanlp", "-Xms1g", "-Xmx1g")
22 |
23 |
24 | paraStr1='中国科学院计算技术研究所的宗成庆教授正在教授自然语言处理课程'
25 |
26 | print("="*30+"HanLP分词"+"="*30)
27 | HanLP = JClass('com.hankcs.hanlp.HanLP')
28 | print(HanLP.segment(paraStr1))
29 |
30 |
31 |
32 | print("="*30+"标准分词"+"="*30)
33 | StandardTokenizer = JClass('com.hankcs.hanlp.tokenizer.StandardTokenizer')
34 | print(StandardTokenizer.segment(paraStr1))
35 |
36 |
37 |
38 | # NLP分词NLPTokenizer会执行全部命名实体识别和词性标注
39 | print("="*30+"NLP分词"+"="*30)
40 | NLPTokenizer = JClass('com.hankcs.hanlp.tokenizer.NLPTokenizer')
41 | print(NLPTokenizer.segment(paraStr1))
42 |
43 |
44 |
45 | print("="*30+"索引分词"+"="*30)
46 | IndexTokenizer = JClass('com.hankcs.hanlp.tokenizer.IndexTokenizer')
47 | termList= IndexTokenizer.segment(paraStr1);
48 | for term in termList :
49 | print(str(term) + " [" + str(term.offset) + ":" + str(term.offset + len(term.word)) + "]")
50 |
51 |
52 |
53 | print("="*30+" 极速词典分词"+"="*30)
54 | SpeedTokenizer = JClass('com.hankcs.hanlp.tokenizer.SpeedTokenizer')
55 | print(NLPTokenizer.segment(paraStr1))
56 |
57 |
58 |
59 | paraStr2 = '攻城狮逆袭单身狗,迎娶白富美,走上人生巅峰'
60 | print("="*30+" 自定义分词"+"="*30)
61 | CustomDictionary = JClass('com.hankcs.hanlp.dictionary.CustomDictionary')
62 | CustomDictionary.add('攻城狮')
63 | CustomDictionary.add('单身狗')
64 | HanLP = JClass('com.hankcs.hanlp.HanLP')
65 | print(HanLP.segment(paraStr2))
66 |
67 |
68 |
69 | print("="*20+"命名实体识别与词性标注"+"="*30)
70 | NLPTokenizer = JClass('com.hankcs.hanlp.tokenizer.NLPTokenizer')
71 | print(NLPTokenizer.segment(paraStr1))
72 |
73 |
74 |
75 | paraStr3="水利部水资源司司长陈明忠9月29日在国务院新闻办举行的新闻发布会上透露,根据刚刚完成了水资源管理制度的考核,有部分省接近了红线的指标,有部分省超过红线的指标。对一些超过红线的地方,陈明忠表示,对一些取用水项目进行区域的限批,严格地进行水资源论证和取水许可的批准。"
76 | print("="*30+"关键词提取"+"="*30)
77 | print(HanLP.extractKeyword(paraStr3, 8))
78 |
79 | paraStr0 ="据报道,2017年5月,为了承接一项工程,来自河南一家建筑公司的柳先生和十几名同事被派到南京做前期筹备工作。为了节约开支,大伙商量决定采取A A制的方式搭伙做饭。不料,2017年11月建邺区市场监管局(下称市监局)上门进行检查,要求柳先生等人不得在出租房内做饭,并且开出了一份《行政处罚听证告知书》。《告知书》显示柳先生等人搭伙做饭属于“未经许可从事食品经营的行为”,并认定其违法收入为14160元,加上10倍的罚款,总共要处罚155760元。对此,柳先生等人表示很不能理解市监局的这一处罚。因协商无果,柳先生等人已就此提起申诉。而在此之后,市监局向媒体提供了一份建筑公司出具的情况说明,证明该建筑公司承认出租房为单位员工食堂。针对此事,很快热议如潮。甚至有网友感慨道:“原来自己吃饭也要办理《食品生产经营卫生许可证》!”在当下食品卫生问题备受关注的大环境下,此次执法行动非但没有因其严格而受到好评,反而受到民众的质疑,这着实令人深思。\
80 | \
81 | 根据《餐饮服务食品安全操作规范》规定,食堂指设于机关、学校(含托幼机构)、企事业单位、建筑工地等地点(场所),供应内部职工、学生等就餐的提供者。建邺区市监局就是根据这一规定认定柳先生等人的搭伙做饭属于开设食堂的。而作为食堂就应该遵守食品安全法第35条第1款规定,必须有食品经营许可证。《食品安全法》第35条第1款的确规定了,从事食品生产、食品销售、餐饮服务,应当依法取得许可。\
82 | \
83 | 为了证明是食堂,案发后,建邺区市监局还向媒体提供了一份该建筑公司的“情况说明”。而被处罚方柳先生表示,“该情况说明和授权书都是在市监局的工作人员诱导下写的,当时他们承诺不罚款,我们才按照他们给的模板写的”,“单位一开始不愿意盖章,协商了好几天才盖了章”。那么真相到底是什么?到底是员工个人搭伙做饭,还是公司开办的简易食堂,双方各执一词。不过,认定是否开设食堂,不能仅以单位自我“说明”为依据,而应该依照事实做出判别。如果是单位食堂,必须由单位出钱购买一切厨房用具,以及食品原材料,安排有专门的厨师,还要有专门的经营管理者。单位不能仅仅是在找地方解决了员工吃饭问题这个意义上自认食堂。对此,柳先生还说:“比如说买100块钱的菜,我们5个人吃,就一人20块钱,烧菜的师傅是不赚一分钱的。因此,张师傅做的饭一没出售二没盈利,怎么就成了‘食品经营行为’?”\
84 | \
85 | 与此同时,南京市别的几个区市监局工作人员则表示,柳先生等人搭伙做饭规模小,而且是在民宅内,不需要办理许可证,只要做到不扰民就行。也就是说,同在南京市的不同市监局的态度完全不同,那这究竟是理解上有偏差,还是执法上的随意扩张呢?实际上,食品安全法第36条还规定,食品生产加工小作坊和食品摊贩等从事食品生产经营活动,应当符合本法规定的与其生产经营规模、条件相适应的食品安全要求,保证所生产经营的食品卫生、无毒、无害,食品药品监督管理部门应当对其加强监督管理。这一条对“小作坊和食品摊贩”等从事食品生产经营活动只提出“与其生产经营规模、条件相适应的食品安全要求”,这也说明,不是只要有食品生产就必须去办个许可证,否则那些小摊小贩小作坊就根本没有存在的空间,可社会又实实在在需要它们。\
86 | \
87 | 再就处罚而言,根据《食品安全法》规定,未取得食品生产经营许可从事食品生产经营活动,由县级以上人民政府食品药品监督管理部门没收违法所得和违法生产经营的食品以及用于违法生产经营的工具、设备、原料等物品;违法生产经营的食品货值金额不足一万元的,并处五万元以上十万元以下罚款;货值金额一万元以上的,并处货值金额十倍以上二十倍以下罚款。再次,法律强调的处罚依据是“食品货值”,“货值”与为分摊成本而进行的搭伙做的饭菜有明显区别,这种搭伙的“自给自足”行为在本质上仍然属于自己做饭自己吃,只不过吃饭的人比单独的一家人或几家人多。这样的执法就有管得太宽、管得太随意之嫌。就当是该管,也有高射炮打蚊子的嫌疑。\
88 | \
89 | 媒体还报道了此次执法人员的蛮横无理:“不要跟我谈凑钱,你那白纸黑字的东西都在这里,我跟你讲有问题,你要跟我狡辩,我们之间免谈,不交按20倍处罚,我管你,我们就等你告我们。”这番滥用法律当“威胁”筹码的语调,让国家机关工作人员的公正执法形象荡然无存。这一事件再次验证了基层执法矛盾与部分执法人员执法水平低,且容易滥用执法权,因而选择性地实施作为或者不作为大有关系。\
90 | \
91 | 作为食品药品安全卫生监督管理部门,市监局严格认真执法本无可厚非。但此次重罚搭伙吃饭的做法除了反映执法能力问题外,滥用执法权力的冲动亦不可忽视。每一个执法者都须切记,执法的核心宗旨是保护公民的合法权益,人民授予的权力更不可被滥用。"
92 |
93 |
94 | print("="*30+"自动摘要"+"="*30)
95 | print(HanLP.extractSummary(paraStr0, 5))
96 |
97 |
98 |
99 | paraStr4=["武胜县新学乡政府大楼门前锣鼓喧天","蓝翔给宁夏固原市彭阳县红河镇黑牛沟村捐赠了挖掘机"]
100 | print("="*30+"地名识别"+"="*30)
101 | HanLP = JClass('com.hankcs.hanlp.HanLP')
102 | segment = HanLP.newSegment().enablePlaceRecognize(True)
103 | for sentence in paraStr4 :
104 | print(HanLP.segment(sentence))
105 |
106 |
107 |
108 | paraStr5="徐先生还具体帮助他确定了把画雄鹰、松鼠和麻雀作为主攻目标。"
109 | print("="*30+"依存句法分析"+"="*30)
110 | print(HanLP.parseDependency(paraStr5))
111 |
112 |
113 |
114 |
115 | text =r"算法工程师\n 算法(Algorithm)是一系列解决问题的清晰指令,也就是说,能够对一定规范的输入,在有限时间内获得所要求的输出。如果一个算法有缺陷,或不适合于某个问题,执行这个算法将不会解决这个问题。不同的算法可能用不同的时间、空间或效率来完成同样的任务。一个算法的优劣可以用空间复杂度与时间复杂度来衡量。算法工程师就是利用算法处理事物的人。\n \n 1职位简介\n 算法工程师是一个非常高端的职位;\n 专业要求:计算机、电子、通信、数学等相关专业;\n 学历要求:本科及其以上的学历,大多数是硕士学历及其以上;\n 语言要求:英语要求是熟练,基本上能阅读国外专业书刊;\n 必须掌握计算机相关知识,熟练使用仿真工具MATLAB等,必须会一门编程语言。\n\n2研究方向\n 视频算法工程师、图像处理算法工程师、音频算法工程师 通信基带算法工程师\n \n 3目前国内外状况\n 目前国内从事算法研究的工程师不少,但是高级算法工程师却很少,是一个非常紧缺的专业工程师。算法工程师根据研究领域来分主要有音频/视频算法处理、图像技术方面的二维信息算法处理和通信物理层、雷达信号处理、生物医学信号处理等领域的一维信息算法处理。\n 在计算机音视频和图形图像技术等二维信息算法处理方面目前比较先进的视频处理算法:机器视觉成为此类算法研究的核心;另外还有2D转3D算法(2D-to-3D conversion),去隔行算法(de-interlacing),运动估计运动补偿算法(Motion estimation/Motion Compensation),去噪算法(Noise Reduction),缩放算法(scaling),锐化处理算法(Sharpness),超分辨率算法(Super Resolution),手势识别(gesture recognition),人脸识别(face recognition)。\n 在通信物理层等一维信息领域目前常用的算法:无线领域的RRM、RTT,传送领域的调制解调、信道均衡、信号检测、网络优化、信号分解等。\n 另外数据挖掘、互联网搜索算法也成为当今的热门方向。\n"
116 | print("="*30+"短语提取"+"="*30)
117 | print(HanLP.extractPhrase(text, 10))
118 |
119 |
120 | shutdownJVM()
--------------------------------------------------------------------------------
/ProcessText/StopWords.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description:自定义去停用词
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import re,jieba,sys
10 |
11 | # 加载自定义分词词典
12 | jieba.load_userdict("../dataSet/StopWord/user_dict.txt")
13 |
14 |
15 | #********************1 结巴中文分词***********************************
16 |
17 | # 利用jieba对文本进行分词,返回切词后的list
18 | def seg_doc(str_doc):
19 | # 1 正则处理原文本
20 | sent_list = str_doc.split('\n')
21 | # map内置高阶函数:一个函数f和list,函数f依次作用在list.
22 | sent_list = map(textParse, sent_list) # 正则处理,去掉一些字符,例如\u3000
23 |
24 | # 2 获取停用词
25 | stwlist = get_stop_words()
26 |
27 | # 3 分词并去除停用词
28 | word_2dlist = [rm_tokens(jieba.cut(part, cut_all=False),stwlist) for part in sent_list]
29 |
30 | # 4 合并列表
31 | word_list = sum(word_2dlist, [])
32 | return word_list
33 |
34 |
35 | # 正则对字符串清洗
36 | def textParse(str_doc):
37 | # 正则过滤掉特殊符号、标点、英文、数字等。
38 | # r1 = '[a-zA-Z0-9’!"#$%&\'()*+,-./::;;|<=>?@,—。?★、…【】《》?“”‘’![\\]^_`{|}~]+'
39 | # str_doc=re.sub(r1, ' ', str_doc)
40 |
41 | # 去掉字符
42 | str_doc = re.sub('\u3000', '', str_doc)
43 |
44 | # 去除空格
45 | # str_doc=re.sub('\s+', ' ', str_doc)
46 |
47 | # 去除换行符
48 | # str_doc = str_doc.replace('\n',' ')
49 | return str_doc
50 |
51 |
52 | # 创建停用词列表
53 | def get_stop_words(path=r'../dataSet/StopWord/NLPIR_stopwords.txt'):
54 | file = open(path, 'r',encoding='utf-8').read().split('\n')
55 | return set(file)
56 |
57 | # 去掉一些停用词和数字
58 | def rm_tokens(words,stwlist):
59 | words_list = list(words)
60 | stop_words = stwlist
61 | for i in range(words_list.__len__())[::-1]:
62 | if words_list[i] in stop_words: # 去除停用词
63 | words_list.pop(i)
64 | elif words_list[i].isdigit(): # 去除数字
65 | words_list.pop(i)
66 | elif len(words_list[i]) == 1: # 去除单个字符
67 | words_list.pop(i)
68 | elif words_list[i] == " ": # 去除空字符
69 | words_list.pop(i)
70 | return words_list
71 |
72 |
73 | # 读取文本信息
74 | def readFile(path):
75 | str_doc = ""
76 | with open(path,'r',encoding='utf-8') as f:
77 | str_doc = f.read()
78 | return str_doc
79 |
80 |
81 |
82 | if __name__=='__main__':
83 | # 1 读取文本
84 | path= r'../dataSet/CSCMNews/体育/0.txt'
85 | str_doc = readFile(path)
86 | # print(str_doc)
87 |
88 | # 2 分词去停用词
89 | word_list = seg_doc(str_doc)
90 | print(word_list)
--------------------------------------------------------------------------------
/ProcessText/TFIDF.py:
--------------------------------------------------------------------------------
1 | # coding:utf8
2 |
3 | """
4 | Description: 利用sklearn计算tfidf值特征
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | from StopWords import readFile,seg_doc
10 | from sklearn.feature_extraction.text import TfidfTransformer
11 | from sklearn.feature_extraction.text import CountVectorizer
12 |
13 |
14 | # 利用sklearn计算tfidf值特征
15 | def sklearn_tfidf_feature(corpus=None):
16 | # 该类会将文本中的词语转换为词频矩阵,矩阵元素a[i][j] 表示j词在i类文本下的词频
17 | vectorizer = CountVectorizer() # 构建词汇表
18 | transformer = TfidfTransformer() # 该类会统计每个词语的tf-idf权值
19 | tfidf = transformer.fit_transform(vectorizer.fit_transform(corpus)) # 第一个fit_transform是计算tf-idf,第二个fit_transform是将文本转为词频矩阵
20 | word = vectorizer.get_feature_names() # 获取词袋模型中的所有词语
21 | weight = tfidf.toarray() # 将tf-idf矩阵抽取出来,元素a[i][j]表示j词在i类文本中的tf-idf权重
22 | for i in range(len(weight)): # 打印每类文本的tf-idf词语权重,第一个for遍历所有文本,第二个for便利某一类文本下的词语权重
23 | print(u"-------这里输出第", i, u"类文本的词语tf-idf权重------")
24 | for j in range(len(word)):
25 | print(word[j], weight[i][j])
26 |
27 | if __name__=='__main__':
28 | corpus =[]
29 | # corpus参数样例数据如下:
30 | # corpus = ["我 来到 成都 成都 春熙路 很 开心",
31 | # "今天 在 宽窄巷子 耍 了 一天 ",
32 | # "成都 整体 来说 还是 挺 安逸 的",
33 | # "成都 的 美食 真 巴适 惨 了"]
34 | # 1 读取文本
35 | path1= r'../dataSet/CSCMNews/体育/0.txt'
36 | str_doc1 = readFile(path1)
37 | word_list1 =' '.join(seg_doc(str_doc1))
38 |
39 | path2= r'../dataSet/CSCMNews/时政/339764.txt'
40 | str_doc2 = readFile(path2)
41 | word_list2 =' '.join(seg_doc(str_doc2))
42 |
43 | corpus.append(word_list1)
44 | corpus.append(word_list2)
45 |
46 | sklearn_tfidf_feature(corpus)
--------------------------------------------------------------------------------
/ProcessText/__pycache__/FreqWord.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/ProcessText/__pycache__/FreqWord.cpython-35.pyc
--------------------------------------------------------------------------------
/ProcessText/__pycache__/StopWords.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/ProcessText/__pycache__/StopWords.cpython-35.pyc
--------------------------------------------------------------------------------
/ProcessText/jiebaCut.py:
--------------------------------------------------------------------------------
1 | #coding:utf8
2 |
3 | """
4 | Description: jieba分词操作详解
5 | Author:伏草惟存
6 | Prompt: code in Python3 env
7 | """
8 |
9 | import jieba,os
10 | import jieba.posseg
11 | import jieba.analyse
12 |
13 |
14 | '''
15 | 支持三种分词模式与特点:
16 | 精确模式:试图将句子最精确地切开,适合文本分析;
17 | 全模式:把句子中所有的可以成词的词语都扫描出来, 速度非常快,但是不能解决歧义;
18 | 搜索引擎模式:在精确模式的基础上,对长词再次切分,提高召回率,适合用于搜索引擎分词。
19 | 支持繁体分词
20 | 支持自定义词典
21 | 安装方法:
22 | 自动安装: pip install jieba
23 | 半自动安装:下载 http://pypi.python.org/pypi/jieba/解压后运行 python setup.py install
24 | 手动安装:将 jieba 目录放置于当前目录或者 site-packages 目录,
25 | 通过 import jieba 来引用
26 |
27 | 核心算法:
28 | 基于前缀词典实现高效的词图扫描,生成句子中汉字所有可能成词情况所构成的有向无环图 (DAG)
29 | 采用了动态规划查找最大概率路径, 找出基于词频的最大切分组合
30 | 对于未登录词,采用了基于汉字成词能力的 HMM 模型,使用了 Viterbi 算法
31 | 主要功能:
32 | jieba.cut 三个输入参数: 待分词的字符串;cut_all参数是否全模式;HMM 参数是否 HMM 模型
33 | jieba.cut_for_search 两个参数:待分词的字符串;是否 HMM 模型。该方法适合用于搜索引擎构建倒排索引的分词,粒度比较细
34 | jieba.lcut 以及 jieba.lcut_for_search 直接返回 list
35 | jieba.Tokenizer(dictionary=DEFAULT_DICT) 新建自定义分词器,可用于同时使用不同词典。jieba.dt 为默认分词器。
36 |
37 | '''
38 |
39 |
40 | #********************1 结巴中文分词基本操作***********************************
41 |
42 | print('='*40)
43 | print('1. 分词')
44 | print('-'*40)
45 |
46 | # 1 全模式,扫描所有可以成词的词语, 速度非常快,不能解决歧义.
47 | seg_list = jieba.cut("我来到成都四川大学", cut_all=True)
48 | print("\nFull Mode: " + "/ ".join(seg_list))
49 |
50 | # 2 默认是精确模式,适合文本分析.
51 | seg_list = jieba.cut("我来到成都四川大学", cut_all=False)
52 | print("\nDefault Mode: " + "/ ".join(seg_list)) # 默认模式
53 |
54 | seg_list = jieba.cut("他来到了网易杭研大厦")
55 | print('\n默认切词:'+"/ ".join(seg_list))
56 |
57 | # 3 搜索引擎模式,对长词再次切分,提高召回率,适合用于搜索引擎分词。
58 | #jieba.cut_for_search 该方法适合用于搜索引擎构建倒排索引的分词,粒度比较细
59 |
60 | seg_list = jieba.cut_for_search("小明硕士毕业于中国科学院计算所,后在日本京都大学深造",HMM=False)
61 | print('\n搜索引擎模式:'+", ".join(seg_list))
62 |
63 |
64 |
65 | print('='*40)
66 | print('2. 添加自定义词典/调整词典')
67 | print('-'*40)
68 |
69 | print('原文档:\t'+'/'.join(jieba.cut('如果放到数据库中将出错。', HMM=False)))
70 | #如果/放到/数据库/中将/出错/。
71 | print(jieba.suggest_freq(('中', '将'), True))
72 | #494
73 | print('改进文档:\t'+'/'.join(jieba.cut('如果放到数据库中将出错。', HMM=False)))
74 | #如果/放到/数据库/中/将/出错/。
75 | print('\n原文档:\t'+'/'.join(jieba.cut('「台中」正确应该不会被切开', HMM=False)))
76 | #「/台/中/」/正确/应该/不会/被/切开
77 | print(jieba.suggest_freq('台中', True))
78 | #69
79 | print('改进文档:\t'+'/'.join(jieba.cut('「台中」正确应该不会被切开', HMM=False)))
80 | #「/台中/」/正确/应该/不会/被/切开
81 |
82 | #********************2 加载自定义分词词典***********************************
83 | import sys
84 | sys.path.append("../")
85 | jieba.load_userdict("../dataSet/StopWord/user_dict.txt") # 加载自定义分词词典
86 |
87 | seg_list1 = jieba.cut("今天很高兴在慕课网和大家交流学习")
88 | print('\n\n加载自定义分词词典:\n'+"/ ".join(seg_list1))
89 |
90 |
91 | print('='*40)
92 | print('3. 关键词提取')
93 | print('-'*40)
94 | print(' TF-IDF')
95 | print('-'*40)
96 |
97 | '''
98 | extract_tags(sentence, topK=20, withWeight=False, allowPOS=())
99 | sentence 为待提取的文本
100 | topK 为返回几个 TF/IDF 权重最大的关键词,默认值为 20
101 | withWeight 为是否一并返回关键词权重值,默认值为 False
102 | allowPOS 仅包括指定词性的词,默认值为空,即不筛选
103 | jieba.analyse.TFIDF(idf_path=None) 新建 TFIDF 实例,idf_path 为 IDF 频率文件
104 | '''
105 | s = "此外,公司拟对全资子公司吉林欧亚置业有限公司增资4.3亿元,增资后,吉林欧亚置业注册资本由7000万元增加到5亿元。吉林欧亚置业主要经营范围为房地产开发及百货零售等业务。目前在建吉林欧亚城市商业综合体项目。2013年,实现营业收入0万元,实现净利润-139.13万元。"
106 | for x, w in jieba.analyse.extract_tags(s,10, withWeight=True):
107 | print('%s %s' % (x, w))
108 |
109 | print('-'*40)
110 | print(' TextRank')
111 | print('-'*40)
112 |
113 |
114 | # textrank(sentence, topK=20, withWeight=False, allowPOS=('ns', 'n', 'vn', 'v')) 直接使用,接口相同,注意默认过滤词性。
115 |
116 | for x, w in jieba.analyse.textrank(s, 10,withWeight=True):
117 | print('%s %s' % (x, w))
118 |
119 |
120 | print('='*40)
121 | print('4. 词性标注')
122 | print('-'*40)
123 |
124 | words = jieba.posseg.cut("我爱北京天安门")
125 | for word, flag in words:
126 | print('%s %s' % (word, flag))
127 |
128 | print('='*40)
129 | print('6. Tokenize: 返回词语在原文的起止位置')
130 | print('-'*40)
131 | print(' 默认模式')
132 | print('-'*40)
133 |
134 | result = jieba.tokenize('永和服装饰品有限公司')
135 | for tk in result:
136 | print("word %s\t\t start: %d \t\t end:%d" % (tk[0],tk[1],tk[2]))
137 |
138 | print('-'*40)
139 | print(' 搜索模式')
140 | print('-'*40)
141 |
142 | result = jieba.tokenize('永和服装饰品有限公司', mode='search')
143 | for tk in result:
144 | print("word %s\t\t start: %d \t\t end:%d" % (tk[0],tk[1],tk[2]))
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 慕课网公开课:《Python数据预处理》
2 |
3 | 本课程是作者跟慕课网合作开发的一款数据预处理课程,归作者和慕课网共同所有,仅限学习使用。
4 |
5 | > 技术交流群
6 | 机器学习和自然语言(QQ群号:436303759)是一个研究深度学习、机器学习、自然语言处理、数据挖掘、图像处理、目标检测、数据科学等AI相关领域的技术群。其宗旨是纯粹的AI技术圈子、绿色的交流环境。为解决成员交流中的时间壁垒,为提高群体技术交流效率。本群禁止有违背法律法规和道德的言谈举止。群成员备注格式:城市-自命名。微信订阅号:datathinks
7 |
8 |
9 | ## 第一部分:抽取多源数据文本信息
10 |
11 | ### 第一章:Python数据预处理介绍
12 | - 第一小节:什么是数据预处理
13 | - 第二小节:为什么做这门课
14 | - 第三小节:本课程可以学习到什么
15 | - 第四小节:开发环境说明
16 | - 第五小节:课程体系介绍
17 | - 第六小节:源码获取
18 |
19 | ### 第二章:抽取文本信息
20 | - 第一小节:常见数据类型与采集策略
21 | - 第二小节:一堆杂乱无章的数据
22 | - 第三小节: 文本抽取的3种方法分析
23 | - 第四小节:Pywin32实现文本格式转换
24 | - 第五小节:抽取Word文本算法实现
25 | - 第六小节:抽取PDF文本算法实现
26 | - 第七小节:文本抽取与编码工具的封装
27 | - 第八小节:批量读取目录文件
28 | - 第九小节:实战案例:遍历文件自动抽取新闻文本
29 |
30 |
31 | ## 第二部分:清洗文本数据
32 |
33 | ### 第三章:清洗文本信息
34 | - 第一小节:准备30万新闻数据
35 | - 第二小节:Yield生成器
36 | - 第三小节: 递归方法遍历30万新闻
37 | - 第四小节: 高效方法遍历30万新闻
38 | - 第五小节: 正则清洗字符串数据
39 | - 第六小节: 正则清洗网页数据
40 | - 第七小节: 简繁字体转换
41 | - 第八小节:实战案例:高效批量清洗新闻文本数据
42 |
43 | ### 第四章: 文本特征提取
44 | - 第一小节:结巴分词精讲
45 | - 第二小节:HanLp分词精讲
46 | - 第三小节:自定义去除停用词
47 | - 第四小节:NLTK词频统计
48 | - 第五小节:高低词频选择方法
49 | - 第六小节: 命名实体快捷抽取
50 | - 第七小节: 计算多分类下的TF-IDF值
51 | - 第八小节:实战案例:高效批量提取新闻文本特征
52 |
53 |
54 | ## 第三部分:文本特征向量化
55 |
56 | ### 第五章:手工实现文本特征向量化
57 | - 第一小节:解析数据文件
58 | - 第二小节:处理数据缺失值
59 | - 第三小节:不均衡数据归一化
60 | - 第四小节: 计算文本相似度
61 | - 第五小节:特征词转文本向量
62 | - 第六小节:词频与逆词频TF-IDF
63 | - 第七小节:词集模型与词袋模型
64 | - 第八小节:实战案例:新闻文本特征向量化
65 |
66 | ### 第六章: Gensim实现文本特征向量化
67 | - 第一小节:Ginsim介绍
68 | - 第二小节:Ginsim 构造语料词典
69 | - 第三小节:Ginsim统计特征词频
70 | - 第四小节:Ginsim 计算TF-IDF
71 | - 第五小节:LSA潜在语义分析主题实现
72 | - 第六小节: LDA隐含狄利克雷分布主题实现
73 | - 第七小节: RP生成随机映射主题实现
74 | - 第八小节:HDP分层狄利克雷过程主题实现
75 | - 第九小节:实战案例:Gensim实现新闻文本特征向量化
76 |
77 | ## 第四部分:特征降维与可视化
78 |
79 | ### 第七章:主成分分析PCA实现特征降维
80 | - 第一小节:数据降维介绍
81 | - 第二小节:二维数据降维
82 | - 第三小节:PCA 算法原理与实现
83 | - 第四小节: PCA降维特征可视化
84 | - 第五小节:特征数据主成分分析
85 | - 第六小节:实战案例:PCA技术实现新闻文本特征降维
86 |
87 | ### 第八章: Matplotlib数据可视化
88 | - 第一小节:Matplotlib介绍
89 | - 第二小节:Matplotlib绘制折线图
90 | - 第三小节:Matplotlib绘制散点图
91 | - 第四小节:Matplotlib绘制直方图
92 | - 第五小节:Matplotlib绘制复杂图
93 | - 第六小节:Matplotlib绘制3D图
94 |
95 |
96 | ## 第五部分:XGBoost实现网络新闻自动分类
97 | ### 第九章: XGBoost实现新闻文本分类
98 | - 第一小节:文本分类概述
99 | - 第二小节:XGBoost概述
100 | - 第三小节:XGBoost官方案例:预测毒蘑菇
101 | - 第四小节:XGBoost 参数介绍
102 | - 第五小节:XGBoost 调参案例:预测糖尿病患者
103 | - 加载官网比赛数据
104 | - 训练算法模型
105 | - 最佳决策树
106 | - 最佳min_child_weight和max_depth
107 | - 最佳gamma和subsample
108 | - 最佳参数与结果分析)
109 | - 第六小节:新闻文本数据预处理全过程
110 | - 通用方法类库
111 | - 生成词典模型
112 | - 生成TF-IDF向量模型
113 | - 生成LSI主题模型
114 | - 特征降维与选择模型
115 | - 第七小节:XGBoost构建分类器模型
116 | - 第八小节:XGBoots分类器模型评估
117 | - 第九小节:综合案例:XGBoost实现网络新闻自动分类
118 |
119 |
120 |
121 | # 开源视频共享
122 |
123 | 本群倡导"AI技术视频共享"项目,纯粹的收集大家珍藏的技术视频资源,汇少成多,更多的服务大家。本群中的技术视频均由成员无偿自愿上传,以供所有共享者学习。择其部分视频供无共享者成员学习,此技术视频属于公益无偿的,仅供个人学习。不可进行商业活动,违者自行承担后果。截止2019年4月10日经过严格视频质量审核通过的视频为8类包括Python Web技术视频3套、大数据技术视频3套、机器学习技术视频3套、深度学习技术视频8套、数据科学视频6套、数据挖掘视频2套、自然语言处理视频6套和图像处理视频2套,共计33套,约1300G。具体如下:
124 |
125 | - Python Web技术视频
126 | - Django网站开发(贡献者:顽主)
127 | - Python Web开发完整视频(贡献者:顽主)
128 | - Python最新就业班(贡献者:顽主)
129 | - 大数据技术视频
130 | - Hadoop44集入门视频(贡献者:数据思维)
131 | - Hadoop全套视频(贡献者:数据思维)
132 | - Hadoop实战视频(贡献者:数据思维)
133 | - 机器学习技术视频
134 | - 吴恩达机器学习视频(贡献者:烟花易冷)
135 | - 机器学习视频(贡献者:Candymoon)
136 | - 2017机器学习升级(贡献者:北京-sunboy)
137 | - 深度学习技术视频
138 | - Tensorflow源码级技术分享(贡献者:数据思维)
139 | - 深度神经网络算法全套(贡献者:流音)
140 | - 吴恩达深度学习视频(贡献者:烟花易冷)
141 | - 神经网络算法与推荐系统实战(贡献者:水上书)
142 | - 深度学习(贡献者:顽主)
143 | - 深度学习实战视频-人脸检测(贡献者:张顺)
144 | - Tensorflow实战视频-文本分类(贡献者:张顺)
145 | - TensorFlow打造唐诗生成网络(贡献者:张顺)
146 | - 数据科学视频
147 | - Scrapy爬虫框架进阶课程(贡献者:数据思维)
148 | - 分布式爬虫实战视频(贡献者:Timothy)
149 | - Python数据分析与机器学习实战(贡献者:小佐)
150 | - 廖雪峰商业爬虫(贡献者:顽主)
151 | - Python量化金融项目(贡献者:顽主)
152 | - Python数据分析与机器学习实战(贡献者:顽主)
153 | - 数据挖掘视频
154 | - 大数据数据分析与挖掘(贡献者:顽主)
155 | - Python3数据分析与挖掘实战(贡献者:顽主)
156 | - 自然语言处理视频
157 | - 知识图谱视频(贡献者:Candymoon)
158 | - 自然语言处理(贡献者:微笑,向着太阳)
159 | - 知识图谱(贡献者:微笑,向着太阳)
160 | - 机器学习之自然语言处理(贡献者:大白菜)
161 | - 自然语言处理之序列模型(贡献者:无为而立)
162 | - 文本挖掘与自然语言处理(贡献者:海蓝你喜欢吗)
163 | - 图像处理视频
164 | - 中科院图像处理系列课程(贡献者:顽主)
165 | - 2018深度学习之目标检测 (贡献者:顽主)
166 |
--------------------------------------------------------------------------------
/TextClassifier/agaricus.py:
--------------------------------------------------------------------------------
1 | import xgboost as xgb
2 | # 读取数据
3 | dtrain = xgb.DMatrix(r'data/agaricus.txt.train')
4 | dtest = xgb.DMatrix(r'data/agaricus.txt.test')
5 | # 通过 map 指定参数
6 | param = {
7 | 'max_depth':2,
8 | 'eta':1,
9 | 'silent':1,
10 | 'objective':'binary:logistic'
11 | }
12 | num_round = 10
13 | bst = xgb.train(param, dtrain, num_round)
14 | # 预测
15 | preds = bst.predict(dtest)
16 | # print('预测结果:\n',[round(pred) for pred in preds])
17 |
18 | # 验证数据集
19 | watch_list = [(dtest, 'eval'), (dtrain, 'train')]
20 | # 模型训练
21 | bst = xgb.train(param, dtrain, num_round,watch_list)
--------------------------------------------------------------------------------
/TextClassifier/xgb_model.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/TextClassifier/xgb_model.pkl
--------------------------------------------------------------------------------
/dataSet/CSCMNews下载.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/CSCMNews下载.txt
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/1.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/10.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/10.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/11.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/11.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/12.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/12.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/13.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/13.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/14.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/14.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/15.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/15.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/16.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/16.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/17.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/17.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/18.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/18.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/19.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/19.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/2.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/20.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/21.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/21.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/22.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/22.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/23.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/23.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/24.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/24.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/25.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/25.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/26.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/26.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/27.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/27.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/28.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/28.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/29.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/29.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/3.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/30.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/30.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/4.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/5.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/6.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/6.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/7.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/7.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/8.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/8.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/历史/9.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/历史/9.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/1.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/10.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/10.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/11.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/11.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/12.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/12.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/13.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/13.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/14.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/14.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/15.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/15.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/16.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/16.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/17.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/17.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/18.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/18.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/19.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/19.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/2.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/20.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/21.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/21.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/22.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/22.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/23.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/23.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/24.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/24.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/25.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/25.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/26.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/26.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/27.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/27.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/28.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/28.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/29.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/29.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/3.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/30.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/30.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/4.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/5.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/6.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/6.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/7.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/7.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/8.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/8.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/教育/9.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/教育/9.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/1.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/10.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/10.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/11.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/11.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/12.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/12.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/13.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/13.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/14.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/14.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/15.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/15.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/16.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/16.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/17.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/17.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/18.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/18.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/19.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/19.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/2.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/20.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/21.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/21.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/22.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/22.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/23.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/23.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/24.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/24.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/25.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/25.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/26.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/26.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/27.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/27.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/28.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/28.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/29.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/29.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/3.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/30.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/30.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/4.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/5.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/6.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/6.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/7.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/7.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/8.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/8.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/EnPapers/汽车/9.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/EnPapers/汽车/9.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/pdftotxt/2018年世界新闻自由日.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/pdftotxt/2018年世界新闻自由日.pdf
--------------------------------------------------------------------------------
/dataSet/Corpus/wordtotxt/科技项目数据挖掘决策架构.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/Corpus/wordtotxt/科技项目数据挖掘决策架构.docx
--------------------------------------------------------------------------------
/dataSet/StopWord/EN_stopwords.txt:
--------------------------------------------------------------------------------
1 | 'd
2 | 'll
3 | 'm
4 | 're
5 | 's
6 | 't
7 | 've
8 | ZT
9 | ZZ
10 | a
11 | a's
12 | able
13 | about
14 | above
15 | abst
16 | accordance
17 | according
18 | accordingly
19 | across
20 | act
21 | actually
22 | added
23 | adj
24 | adopted
25 | affected
26 | affecting
27 | affects
28 | after
29 | afterwards
30 | again
31 | against
32 | ah
33 | ain't
34 | all
35 | allow
36 | allows
37 | almost
38 | alone
39 | along
40 | already
41 | also
42 | although
43 | always
44 | am
45 | among
46 | amongst
47 | an
48 | and
49 | announce
50 | another
51 | any
52 | anybody
53 | anyhow
54 | anymore
55 | anyone
56 | anything
57 | anyway
58 | anyways
59 | anywhere
60 | apart
61 | apparently
62 | appear
63 | appreciate
64 | appropriate
65 | approximately
66 | are
67 | area
68 | areas
69 | aren
70 | aren't
71 | arent
72 | arise
73 | around
74 | as
75 | aside
76 | ask
77 | asked
78 | asking
79 | asks
80 | associated
81 | at
82 | auth
83 | available
84 | away
85 | awfully
86 | b
87 | back
88 | backed
89 | backing
90 | backs
91 | be
92 | became
93 | because
94 | become
95 | becomes
96 | becoming
97 | been
98 | before
99 | beforehand
100 | began
101 | begin
102 | beginning
103 | beginnings
104 | begins
105 | behind
106 | being
107 | beings
108 | believe
109 | below
110 | beside
111 | besides
112 | best
113 | better
114 | between
115 | beyond
116 | big
117 | biol
118 | both
119 | brief
120 | briefly
121 | but
122 | by
123 | c
124 | c'mon
125 | c's
126 | ca
127 | came
128 | can
129 | can't
130 | cannot
131 | cant
132 | case
133 | cases
134 | cause
135 | causes
136 | certain
137 | certainly
138 | changes
139 | clear
140 | clearly
141 | co
142 | com
143 | come
144 | comes
145 | concerning
146 | consequently
147 | consider
148 | considering
149 | contain
150 | containing
151 | contains
152 | corresponding
153 | could
154 | couldn't
155 | couldnt
156 | course
157 | currently
158 | d
159 | date
160 | definitely
161 | describe
162 | described
163 | despite
164 | did
165 | didn't
166 | differ
167 | different
168 | differently
169 | discuss
170 | do
171 | does
172 | doesn't
173 | doing
174 | don't
175 | done
176 | down
177 | downed
178 | downing
179 | downs
180 | downwards
181 | due
182 | during
183 | e
184 | each
185 | early
186 | ed
187 | edu
188 | effect
189 | eg
190 | eight
191 | eighty
192 | either
193 | else
194 | elsewhere
195 | end
196 | ended
197 | ending
198 | ends
199 | enough
200 | entirely
201 | especially
202 | et
203 | et-al
204 | etc
205 | even
206 | evenly
207 | ever
208 | every
209 | everybody
210 | everyone
211 | everything
212 | everywhere
213 | ex
214 | exactly
215 | example
216 | except
217 | f
218 | face
219 | faces
220 | fact
221 | facts
222 | far
223 | felt
224 | few
225 | ff
226 | fifth
227 | find
228 | finds
229 | first
230 | five
231 | fix
232 | followed
233 | following
234 | follows
235 | for
236 | former
237 | formerly
238 | forth
239 | found
240 | four
241 | from
242 | full
243 | fully
244 | further
245 | furthered
246 | furthering
247 | furthermore
248 | furthers
249 | g
250 | gave
251 | general
252 | generally
253 | get
254 | gets
255 | getting
256 | give
257 | given
258 | gives
259 | giving
260 | go
261 | goes
262 | going
263 | gone
264 | good
265 | goods
266 | got
267 | gotten
268 | great
269 | greater
270 | greatest
271 | greetings
272 | group
273 | grouped
274 | grouping
275 | groups
276 | h
277 | had
278 | hadn't
279 | happens
280 | hardly
281 | has
282 | hasn't
283 | have
284 | haven't
285 | having
286 | he
287 | he's
288 | hed
289 | hello
290 | help
291 | hence
292 | her
293 | here
294 | here's
295 | hereafter
296 | hereby
297 | herein
298 | heres
299 | hereupon
300 | hers
301 | herself
302 | hes
303 | hi
304 | hid
305 | high
306 | higher
307 | highest
308 | him
309 | himself
310 | his
311 | hither
312 | home
313 | hopefully
314 | how
315 | howbeit
316 | however
317 | hundred
318 | i
319 | i'd
320 | i'll
321 | i'm
322 | i've
323 | id
324 | ie
325 | if
326 | ignored
327 | im
328 | immediate
329 | immediately
330 | importance
331 | important
332 | in
333 | inasmuch
334 | inc
335 | include
336 | indeed
337 | index
338 | indicate
339 | indicated
340 | indicates
341 | information
342 | inner
343 | insofar
344 | instead
345 | interest
346 | interested
347 | interesting
348 | interests
349 | into
350 | invention
351 | inward
352 | is
353 | isn't
354 | it
355 | it'd
356 | it'll
357 | it's
358 | itd
359 | its
360 | itself
361 | j
362 | just
363 | k
364 | keep
365 | keeps
366 | kept
367 | keys
368 | kg
369 | kind
370 | km
371 | knew
372 | know
373 | known
374 | knows
375 | l
376 | large
377 | largely
378 | last
379 | lately
380 | later
381 | latest
382 | latter
383 | latterly
384 | least
385 | less
386 | lest
387 | let
388 | let's
389 | lets
390 | like
391 | liked
392 | likely
393 | line
394 | little
395 | long
396 | longer
397 | longest
398 | look
399 | looking
400 | looks
401 | ltd
402 | m
403 | made
404 | mainly
405 | make
406 | makes
407 | making
408 | man
409 | many
410 | may
411 | maybe
412 | me
413 | mean
414 | means
415 | meantime
416 | meanwhile
417 | member
418 | members
419 | men
420 | merely
421 | mg
422 | might
423 | million
424 | miss
425 | ml
426 | more
427 | moreover
428 | most
429 | mostly
430 | mr
431 | mrs
432 | much
433 | mug
434 | must
435 | my
436 | myself
437 | n
438 | n't
439 | na
440 | name
441 | namely
442 | nay
443 | nd
444 | near
445 | nearly
446 | necessarily
447 | necessary
448 | need
449 | needed
450 | needing
451 | needs
452 | neither
453 | never
454 | nevertheless
455 | new
456 | newer
457 | newest
458 | next
459 | nine
460 | ninety
461 | no
462 | nobody
463 | non
464 | none
465 | nonetheless
466 | noone
467 | nor
468 | normally
469 | nos
470 | not
471 | noted
472 | nothing
473 | novel
474 | now
475 | nowhere
476 | number
477 | numbers
478 | o
479 | obtain
480 | obtained
481 | obviously
482 | of
483 | off
484 | often
485 | oh
486 | ok
487 | okay
488 | old
489 | older
490 | oldest
491 | omitted
492 | on
493 | once
494 | one
495 | ones
496 | only
497 | onto
498 | open
499 | opened
500 | opening
501 | opens
502 | or
503 | ord
504 | order
505 | ordered
506 | ordering
507 | orders
508 | other
509 | others
510 | otherwise
511 | ought
512 | our
513 | ours
514 | ourselves
515 | out
516 | outside
517 | over
518 | overall
519 | owing
520 | own
521 | p
522 | page
523 | pages
524 | part
525 | parted
526 | particular
527 | particularly
528 | parting
529 | parts
530 | past
531 | per
532 | perhaps
533 | place
534 | placed
535 | places
536 | please
537 | plus
538 | point
539 | pointed
540 | pointing
541 | points
542 | poorly
543 | possible
544 | possibly
545 | potentially
546 | pp
547 | predominantly
548 | present
549 | presented
550 | presenting
551 | presents
552 | presumably
553 | previously
554 | primarily
555 | probably
556 | problem
557 | problems
558 | promptly
559 | proud
560 | provides
561 | put
562 | puts
563 | q
564 | que
565 | quickly
566 | quite
567 | qv
568 | r
569 | ran
570 | rather
571 | rd
572 | re
573 | readily
574 | really
575 | reasonably
576 | recent
577 | recently
578 | ref
579 | refs
580 | regarding
581 | regardless
582 | regards
583 | related
584 | relatively
585 | research
586 | respectively
587 | resulted
588 | resulting
589 | results
590 | right
591 | room
592 | rooms
593 | run
594 | s
595 | said
596 | same
597 | saw
598 | say
599 | saying
600 | says
601 | sec
602 | second
603 | secondly
604 | seconds
605 | section
606 | see
607 | seeing
608 | seem
609 | seemed
610 | seeming
611 | seems
612 | seen
613 | sees
614 | self
615 | selves
616 | sensible
617 | sent
618 | serious
619 | seriously
620 | seven
621 | several
622 | shall
623 | she
624 | she'll
625 | shed
626 | shes
627 | should
628 | shouldn't
629 | show
630 | showed
631 | showing
632 | shown
633 | showns
634 | shows
635 | side
636 | sides
637 | significant
638 | significantly
639 | similar
640 | similarly
641 | since
642 | six
643 | slightly
644 | small
645 | smaller
646 | smallest
647 | so
648 | some
649 | somebody
650 | somehow
651 | someone
652 | somethan
653 | something
654 | sometime
655 | sometimes
656 | somewhat
657 | somewhere
658 | soon
659 | sorry
660 | specifically
661 | specified
662 | specify
663 | specifying
664 | state
665 | states
666 | still
667 | stop
668 | strongly
669 | sub
670 | substantially
671 | successfully
672 | such
673 | sufficiently
674 | suggest
675 | sup
676 | sure
677 | t
678 | t's
679 | take
680 | taken
681 | taking
682 | tell
683 | tends
684 | th
685 | than
686 | thank
687 | thanks
688 | thanx
689 | that
690 | that'll
691 | that's
692 | that've
693 | thats
694 | the
695 | their
696 | theirs
697 | them
698 | themselves
699 | then
700 | thence
701 | there
702 | there'll
703 | there's
704 | there've
705 | thereafter
706 | thereby
707 | thered
708 | therefore
709 | therein
710 | thereof
711 | therere
712 | theres
713 | thereto
714 | thereupon
715 | these
716 | they
717 | they'd
718 | they'll
719 | they're
720 | they've
721 | theyd
722 | theyre
723 | thing
724 | things
725 | think
726 | thinks
727 | third
728 | this
729 | thorough
730 | thoroughly
731 | those
732 | thou
733 | though
734 | thoughh
735 | thought
736 | thoughts
737 | thousand
738 | three
739 | throug
740 | through
741 | throughout
742 | thru
743 | thus
744 | til
745 | tip
746 | to
747 | today
748 | together
749 | too
750 | took
751 | toward
752 | towards
753 | tried
754 | tries
755 | truly
756 | try
757 | trying
758 | ts
759 | turn
760 | turned
761 | turning
762 | turns
763 | twice
764 | two
765 | u
766 | un
767 | under
768 | unfortunately
769 | unless
770 | unlike
771 | unlikely
772 | until
773 | unto
774 | up
775 | upon
776 | ups
777 | us
778 | use
779 | used
780 | useful
781 | usefully
782 | usefulness
783 | uses
784 | using
785 | usually
786 | uucp
787 | v
788 | value
789 | various
790 | very
791 | via
792 | viz
793 | vol
794 | vols
795 | vs
796 | w
797 | want
798 | wanted
799 | wanting
800 | wants
801 | was
802 | wasn't
803 | way
804 | ways
805 | we
806 | we'd
807 | we'll
808 | we're
809 | we've
810 | wed
811 | welcome
812 | well
813 | wells
814 | went
815 | were
816 | weren't
817 | what
818 | what'll
819 | what's
820 | whatever
821 | whats
822 | when
823 | whence
824 | whenever
825 | where
826 | where's
827 | whereafter
828 | whereas
829 | whereby
830 | wherein
831 | wheres
832 | whereupon
833 | wherever
834 | whether
835 | which
836 | while
837 | whim
838 | whither
839 | who
840 | who'll
841 | who's
842 | whod
843 | whoever
844 | whole
845 | whom
846 | whomever
847 | whos
848 | whose
849 | why
850 | widely
851 | will
852 | willing
853 | wish
854 | with
855 | within
856 | without
857 | won't
858 | wonder
859 | words
860 | work
861 | worked
862 | working
863 | works
864 | world
865 | would
866 | wouldn't
867 | www
868 | x
869 | y
870 | year
871 | years
872 | yes
873 | yet
874 | you
875 | you'd
876 | you'll
877 | you're
878 | you've
879 | youd
880 | young
881 | younger
882 | youngest
883 | your
884 | youre
885 | yours
886 | yourself
887 | yourselves
888 | z
889 | zero
890 | zt
891 | zz
--------------------------------------------------------------------------------
/dataSet/StopWord/NLPIR_stopwords.txt:
--------------------------------------------------------------------------------
1 | !
2 | "
3 | #
4 | $
5 | %
6 | &
7 | '
8 | (
9 | )
10 | *
11 | +
12 | ,
13 | -
14 |
15 | --
16 | .
17 | ..
18 | ...
19 | ......
20 | ...................
21 | ./
22 | .一
23 | .数
24 | .日
25 | /
26 | //
27 | 0
28 | 1
29 | 2
30 | 3
31 | 4
32 | 5
33 | 6
34 | 7
35 | 8
36 | 9
37 | :
38 | ://
39 | ::
40 | ;
41 | <
42 | =
43 | ■
44 | >
45 | >>
46 | ?
47 | @
48 | A
49 | Lex
50 | [
51 | \
52 | ]
53 | ^
54 | _
55 | `
56 | exp
57 | sub
58 | sup
59 | |
60 | }
61 | ~
62 | ~~~~
63 | ×
64 | ×××
65 | Δ
66 | Ψ
67 | γ
68 | μ
69 | φ
70 | φ.
71 | В
72 | —
73 | ——
74 | ———
75 | ‘
76 | ’
77 | ’‘
78 | “
79 | ”
80 | ”,
81 | …
82 | ……
83 | …………………………………………………③
84 | ′∈
85 | ′|
86 | ℃
87 | Ⅲ
88 | ↑
89 | →
90 | ∈[
91 | ∪φ∈
92 | ≈
93 | ①
94 | ②
95 | ②c
96 | ③
97 | ③]
98 | ④
99 | ⑤
100 | ⑥
101 | ⑦
102 | ⑧
103 | ⑨
104 | ⑩
105 | ──
106 | ■
107 | ▲
108 |
109 | 、
110 | 。
111 | 〈
112 | 〉
113 | 《
114 | 》
115 | 》),
116 | 」
117 | 『
118 | 』
119 | 【
120 | 】
121 | 〔
122 | 〕
123 | 〕〔
124 | ㈧
125 | 一
126 | 一.
127 | 一一
128 | 一下
129 | 一个
130 | 一些
131 | 一何
132 | 一切
133 | 一则
134 | 一则通过
135 | 一天
136 | 一定
137 | 一方面
138 | 一旦
139 | 一时
140 | 一来
141 | 一样
142 | 一次
143 | 一片
144 | 一番
145 | 一直
146 | 一致
147 | 一般
148 | 一起
149 | 一转眼
150 | 一边
151 | 一面
152 | 七
153 | 万一
154 | 三
155 | 三天两头
156 | 三番两次
157 | 三番五次
158 | 上
159 | 上下
160 | 上升
161 | 上去
162 | 上来
163 | 上述
164 | 上面
165 | 下
166 | 下列
167 | 下去
168 | 下来
169 | 下面
170 | 不
171 | 不一
172 | 不下
173 | 不久
174 | 不了
175 | 不亦乐乎
176 | 不仅
177 | 不仅...而且
178 | 不仅仅
179 | 不仅仅是
180 | 不会
181 | 不但
182 | 不但...而且
183 | 不光
184 | 不免
185 | 不再
186 | 不力
187 | 不单
188 | 不变
189 | 不只
190 | 不可
191 | 不可开交
192 | 不可抗拒
193 | 不同
194 | 不外
195 | 不外乎
196 | 不够
197 | 不大
198 | 不如
199 | 不妨
200 | 不定
201 | 不对
202 | 不少
203 | 不尽
204 | 不尽然
205 | 不巧
206 | 不已
207 | 不常
208 | 不得
209 | 不得不
210 | 不得了
211 | 不得已
212 | 不必
213 | 不怎么
214 | 不怕
215 | 不惟
216 | 不成
217 | 不拘
218 | 不择手段
219 | 不敢
220 | 不料
221 | 不断
222 | 不日
223 | 不时
224 | 不是
225 | 不曾
226 | 不止
227 | 不止一次
228 | 不比
229 | 不消
230 | 不满
231 | 不然
232 | 不然的话
233 | 不特
234 | 不独
235 | 不由得
236 | 不知不觉
237 | 不管
238 | 不管怎样
239 | 不经意
240 | 不胜
241 | 不能
242 | 不能不
243 | 不至于
244 | 不若
245 | 不要
246 | 不论
247 | 不起
248 | 不足
249 | 不过
250 | 不迭
251 | 不问
252 | 不限
253 | 与
254 | 与其
255 | 与其说
256 | 与否
257 | 与此同时
258 | 专门
259 | 且
260 | 且不说
261 | 且说
262 | 两者
263 | 严格
264 | 严重
265 | 个
266 | 个人
267 | 个别
268 | 中小
269 | 中间
270 | 丰富
271 | 串行
272 | 临
273 | 临到
274 | 为
275 | 为主
276 | 为了
277 | 为什么
278 | 为什麽
279 | 为何
280 | 为止
281 | 为此
282 | 为着
283 | 主张
284 | 主要
285 | 举凡
286 | 举行
287 | 乃
288 | 乃至
289 | 乃至于
290 | 么
291 | 之
292 | 之一
293 | 之前
294 | 之后
295 | 之後
296 | 之所以
297 | 之类
298 | 乌乎
299 | 乎
300 | 乒
301 | 乘
302 | 乘势
303 | 乘机
304 | 乘胜
305 | 乘虚
306 | 乘隙
307 | 九
308 | 也
309 | 也好
310 | 也就是说
311 | 也是
312 | 也罢
313 | 了
314 | 了解
315 | 争取
316 | 二
317 | 二来
318 | 二话不说
319 | 二话没说
320 | 于
321 | 于是
322 | 于是乎
323 | 云云
324 | 云尔
325 | 互
326 | 互相
327 | 五
328 | 些
329 | 交口
330 | 亦
331 | 产生
332 | 亲口
333 | 亲手
334 | 亲眼
335 | 亲自
336 | 亲身
337 | 人
338 | 人人
339 | 人们
340 | 人家
341 | 人民
342 | 什么
343 | 什么样
344 | 什麽
345 | 仅
346 | 仅仅
347 | 今
348 | 今后
349 | 今天
350 | 今年
351 | 今後
352 | 介于
353 | 仍
354 | 仍旧
355 | 仍然
356 | 从
357 | 从不
358 | 从严
359 | 从中
360 | 从事
361 | 从今以后
362 | 从优
363 | 从古到今
364 | 从古至今
365 | 从头
366 | 从宽
367 | 从小
368 | 从新
369 | 从无到有
370 | 从早到晚
371 | 从未
372 | 从来
373 | 从此
374 | 从此以后
375 | 从而
376 | 从轻
377 | 从速
378 | 从重
379 | 他
380 | 他人
381 | 他们
382 | 他是
383 | 他的
384 | 代替
385 | 以
386 | 以上
387 | 以下
388 | 以为
389 | 以便
390 | 以免
391 | 以前
392 | 以及
393 | 以后
394 | 以外
395 | 以後
396 | 以故
397 | 以期
398 | 以来
399 | 以至
400 | 以至于
401 | 以致
402 | 们
403 | 任
404 | 任何
405 | 任凭
406 | 任务
407 | 企图
408 | 伙同
409 | 会
410 | 伟大
411 | 传
412 | 传说
413 | 传闻
414 | 似乎
415 | 似的
416 | 但
417 | 但凡
418 | 但愿
419 | 但是
420 | 何
421 | 何乐而不为
422 | 何以
423 | 何况
424 | 何处
425 | 何妨
426 | 何尝
427 | 何必
428 | 何时
429 | 何止
430 | 何苦
431 | 何须
432 | 余外
433 | 作为
434 | 你
435 | 你们
436 | 你是
437 | 你的
438 | 使
439 | 使得
440 | 使用
441 | 例如
442 | 依
443 | 依据
444 | 依照
445 | 依靠
446 | 便
447 | 便于
448 | 促进
449 | 保持
450 | 保管
451 | 保险
452 | 俺
453 | 俺们
454 | 倍加
455 | 倍感
456 | 倒不如
457 | 倒不如说
458 | 倒是
459 | 倘
460 | 倘使
461 | 倘或
462 | 倘然
463 | 倘若
464 | 借
465 | 借以
466 | 借此
467 | 假使
468 | 假如
469 | 假若
470 | 偏偏
471 | 做到
472 | 偶尔
473 | 偶而
474 | 傥然
475 | 像
476 | 儿
477 | 允许
478 | 元/吨
479 | 充其极
480 | 充其量
481 | 充分
482 | 先不先
483 | 先后
484 | 先後
485 | 先生
486 | 光
487 | 光是
488 | 全体
489 | 全力
490 | 全年
491 | 全然
492 | 全身心
493 | 全部
494 | 全都
495 | 全面
496 | 八
497 | 八成
498 | 公然
499 | 六
500 | 兮
501 | 共
502 | 共同
503 | 共总
504 | 关于
505 | 其
506 | 其一
507 | 其中
508 | 其二
509 | 其他
510 | 其余
511 | 其后
512 | 其它
513 | 其实
514 | 其次
515 | 具体
516 | 具体地说
517 | 具体来说
518 | 具体说来
519 | 具有
520 | 兼之
521 | 内
522 | 再
523 | 再其次
524 | 再则
525 | 再有
526 | 再次
527 | 再者
528 | 再者说
529 | 再说
530 | 冒
531 | 冲
532 | 决不
533 | 决定
534 | 决非
535 | 况且
536 | 准备
537 | 凑巧
538 | 凝神
539 | 几
540 | 几乎
541 | 几度
542 | 几时
543 | 几番
544 | 几经
545 | 凡
546 | 凡是
547 | 凭
548 | 凭借
549 | 出
550 | 出于
551 | 出去
552 | 出来
553 | 出现
554 | 分别
555 | 分头
556 | 分期
557 | 分期分批
558 | 切
559 | 切不可
560 | 切切
561 | 切勿
562 | 切莫
563 | 则
564 | 则甚
565 | 刚
566 | 刚好
567 | 刚巧
568 | 刚才
569 | 初
570 | 别
571 | 别人
572 | 别处
573 | 别是
574 | 别的
575 | 别管
576 | 别说
577 | 到
578 | 到了儿
579 | 到处
580 | 到头
581 | 到头来
582 | 到底
583 | 到目前为止
584 | 前后
585 | 前此
586 | 前者
587 | 前进
588 | 前面
589 | 加上
590 | 加之
591 | 加以
592 | 加入
593 | 加强
594 | 动不动
595 | 动辄
596 | 勃然
597 | 匆匆
598 | 十分
599 | 千
600 | 千万
601 | 千万千万
602 | 半
603 | 单
604 | 单单
605 | 单纯
606 | 即
607 | 即令
608 | 即使
609 | 即便
610 | 即刻
611 | 即如
612 | 即将
613 | 即或
614 | 即是说
615 | 即若
616 | 却
617 | 却不
618 | 历
619 | 原来
620 | 去
621 | 又
622 | 又及
623 | 及
624 | 及其
625 | 及时
626 | 及至
627 | 双方
628 | 反之
629 | 反之亦然
630 | 反之则
631 | 反倒
632 | 反倒是
633 | 反应
634 | 反手
635 | 反映
636 | 反而
637 | 反过来
638 | 反过来说
639 | 取得
640 | 取道
641 | 受到
642 | 变成
643 | 古来
644 | 另
645 | 另一个
646 | 另一方面
647 | 另外
648 | 另悉
649 | 另方面
650 | 另行
651 | 只
652 | 只当
653 | 只怕
654 | 只是
655 | 只有
656 | 只消
657 | 只要
658 | 只限
659 | 叫
660 | 叫做
661 | 召开
662 | 叮咚
663 | 叮当
664 | 可
665 | 可以
666 | 可好
667 | 可是
668 | 可能
669 | 可见
670 | 各
671 | 各个
672 | 各人
673 | 各位
674 | 各地
675 | 各式
676 | 各种
677 | 各级
678 | 各自
679 | 合理
680 | 同
681 | 同一
682 | 同时
683 | 同样
684 | 后
685 | 后来
686 | 后者
687 | 后面
688 | 向
689 | 向使
690 | 向着
691 | 吓
692 | 吗
693 | 否则
694 | 吧
695 | 吧哒
696 | 吱
697 | 呀
698 | 呃
699 | 呆呆地
700 | 呐
701 | 呕
702 | 呗
703 | 呜
704 | 呜呼
705 | 呢
706 | 周围
707 | 呵
708 | 呵呵
709 | 呸
710 | 呼哧
711 | 呼啦
712 | 咋
713 | 和
714 | 咚
715 | 咦
716 | 咧
717 | 咱
718 | 咱们
719 | 咳
720 | 哇
721 | 哈
722 | 哈哈
723 | 哉
724 | 哎
725 | 哎呀
726 | 哎哟
727 | 哗
728 | 哗啦
729 | 哟
730 | 哦
731 | 哩
732 | 哪
733 | 哪个
734 | 哪些
735 | 哪儿
736 | 哪天
737 | 哪年
738 | 哪怕
739 | 哪样
740 | 哪边
741 | 哪里
742 | 哼
743 | 哼唷
744 | 唉
745 | 唯有
746 | 啊
747 | 啊呀
748 | 啊哈
749 | 啊哟
750 | 啐
751 | 啥
752 | 啦
753 | 啪达
754 | 啷当
755 | 喀
756 | 喂
757 | 喏
758 | 喔唷
759 | 喽
760 | 嗡
761 | 嗡嗡
762 | 嗬
763 | 嗯
764 | 嗳
765 | 嘎
766 | 嘎嘎
767 | 嘎登
768 | 嘘
769 | 嘛
770 | 嘻
771 | 嘿
772 | 嘿嘿
773 | 四
774 | 因
775 | 因为
776 | 因了
777 | 因此
778 | 因着
779 | 因而
780 | 固
781 | 固然
782 | 在
783 | 在下
784 | 在于
785 | 地
786 | 均
787 | 坚决
788 | 坚持
789 | 基于
790 | 基本
791 | 基本上
792 | 处在
793 | 处处
794 | 处理
795 | 复杂
796 | 多
797 | 多么
798 | 多亏
799 | 多多
800 | 多多少少
801 | 多多益善
802 | 多少
803 | 多年前
804 | 多年来
805 | 多数
806 | 多次
807 | 够瞧的
808 | 大
809 | 大不了
810 | 大举
811 | 大事
812 | 大体
813 | 大体上
814 | 大凡
815 | 大力
816 | 大多
817 | 大多数
818 | 大大
819 | 大家
820 | 大张旗鼓
821 | 大批
822 | 大抵
823 | 大概
824 | 大略
825 | 大约
826 | 大致
827 | 大都
828 | 大量
829 | 大面儿上
830 | 失去
831 | 奇
832 | 奈
833 | 奋勇
834 | 她
835 | 她们
836 | 她是
837 | 她的
838 | 好
839 | 好在
840 | 好的
841 | 好象
842 | 如
843 | 如上
844 | 如上所述
845 | 如下
846 | 如今
847 | 如何
848 | 如其
849 | 如前所述
850 | 如同
851 | 如常
852 | 如是
853 | 如期
854 | 如果
855 | 如次
856 | 如此
857 | 如此等等
858 | 如若
859 | 始而
860 | 姑且
861 | 存在
862 | 存心
863 | 孰料
864 | 孰知
865 | 宁
866 | 宁可
867 | 宁愿
868 | 宁肯
869 | 它
870 | 它们
871 | 它们的
872 | 它是
873 | 它的
874 | 安全
875 | 完全
876 | 完成
877 | 定
878 | 实现
879 | 实际
880 | 宣布
881 | 容易
882 | 密切
883 | 对
884 | 对于
885 | 对应
886 | 对待
887 | 对方
888 | 对比
889 | 将
890 | 将才
891 | 将要
892 | 将近
893 | 小
894 | 少数
895 | 尔
896 | 尔后
897 | 尔尔
898 | 尔等
899 | 尚且
900 | 尤其
901 | 就
902 | 就地
903 | 就是
904 | 就是了
905 | 就是说
906 | 就此
907 | 就算
908 | 就要
909 | 尽
910 | 尽可能
911 | 尽如人意
912 | 尽心尽力
913 | 尽心竭力
914 | 尽快
915 | 尽早
916 | 尽然
917 | 尽管
918 | 尽管如此
919 | 尽量
920 | 局外
921 | 居然
922 | 届时
923 | 属于
924 | 屡
925 | 屡屡
926 | 屡次
927 | 屡次三番
928 | 岂
929 | 岂但
930 | 岂止
931 | 岂非
932 | 川流不息
933 | 左右
934 | 巨大
935 | 巩固
936 | 差一点
937 | 差不多
938 | 己
939 | 已
940 | 已矣
941 | 已经
942 | 巴
943 | 巴巴
944 | 带
945 | 帮助
946 | 常
947 | 常常
948 | 常言说
949 | 常言说得好
950 | 常言道
951 | 平素
952 | 年复一年
953 | 并
954 | 并不
955 | 并不是
956 | 并且
957 | 并排
958 | 并无
959 | 并没
960 | 并没有
961 | 并肩
962 | 并非
963 | 广大
964 | 广泛
965 | 应当
966 | 应用
967 | 应该
968 | 庶乎
969 | 庶几
970 | 开外
971 | 开始
972 | 开展
973 | 引起
974 | 弗
975 | 弹指之间
976 | 强烈
977 | 强调
978 | 归
979 | 归根到底
980 | 归根结底
981 | 归齐
982 | 当
983 | 当下
984 | 当中
985 | 当儿
986 | 当前
987 | 当即
988 | 当口儿
989 | 当地
990 | 当场
991 | 当头
992 | 当庭
993 | 当时
994 | 当然
995 | 当真
996 | 当着
997 | 形成
998 | 彻夜
999 | 彻底
1000 | 彼
1001 | 彼时
1002 | 彼此
1003 | 往
1004 | 往往
1005 | 待
1006 | 待到
1007 | 很
1008 | 很多
1009 | 很少
1010 | 後来
1011 | 後面
1012 | 得
1013 | 得了
1014 | 得出
1015 | 得到
1016 | 得天独厚
1017 | 得起
1018 | 心里
1019 | 必
1020 | 必定
1021 | 必将
1022 | 必然
1023 | 必要
1024 | 必须
1025 | 快
1026 | 快要
1027 | 忽地
1028 | 忽然
1029 | 怎
1030 | 怎么
1031 | 怎么办
1032 | 怎么样
1033 | 怎奈
1034 | 怎样
1035 | 怎麽
1036 | 怕
1037 | 急匆匆
1038 | 怪
1039 | 怪不得
1040 | 总之
1041 | 总是
1042 | 总的来看
1043 | 总的来说
1044 | 总的说来
1045 | 总结
1046 | 总而言之
1047 | 恍然
1048 | 恐怕
1049 | 恰似
1050 | 恰好
1051 | 恰如
1052 | 恰巧
1053 | 恰恰
1054 | 恰恰相反
1055 | 恰逢
1056 | 您
1057 | 您们
1058 | 您是
1059 | 惟其
1060 | 惯常
1061 | 意思
1062 | 愤然
1063 | 愿意
1064 | 慢说
1065 | 成为
1066 | 成年
1067 | 成年累月
1068 | 成心
1069 | 我
1070 | 我们
1071 | 我是
1072 | 我的
1073 | 或
1074 | 或则
1075 | 或多或少
1076 | 或是
1077 | 或曰
1078 | 或者
1079 | 或许
1080 | 战斗
1081 | 截然
1082 | 截至
1083 | 所
1084 | 所以
1085 | 所在
1086 | 所幸
1087 | 所有
1088 | 所谓
1089 | 才
1090 | 才能
1091 | 扑通
1092 | 打
1093 | 打从
1094 | 打开天窗说亮话
1095 | 扩大
1096 | 把
1097 | 抑或
1098 | 抽冷子
1099 | 拦腰
1100 | 拿
1101 | 按
1102 | 按时
1103 | 按期
1104 | 按照
1105 | 按理
1106 | 按说
1107 | 挨个
1108 | 挨家挨户
1109 | 挨次
1110 | 挨着
1111 | 挨门挨户
1112 | 挨门逐户
1113 | 换句话说
1114 | 换言之
1115 | 据
1116 | 据实
1117 | 据悉
1118 | 据我所知
1119 | 据此
1120 | 据称
1121 | 据说
1122 | 掌握
1123 | 接下来
1124 | 接着
1125 | 接著
1126 | 接连不断
1127 | 放量
1128 | 故
1129 | 故意
1130 | 故此
1131 | 故而
1132 | 敞开儿
1133 | 敢
1134 | 敢于
1135 | 敢情
1136 | 数/
1137 | 整个
1138 | 断然
1139 | 方
1140 | 方便
1141 | 方才
1142 | 方能
1143 | 方面
1144 | 旁人
1145 | 无
1146 | 无宁
1147 | 无法
1148 | 无论
1149 | 既
1150 | 既...又
1151 | 既往
1152 | 既是
1153 | 既然
1154 | 日复一日
1155 | 日渐
1156 | 日益
1157 | 日臻
1158 | 日见
1159 | 时候
1160 | 昂然
1161 | 明显
1162 | 明确
1163 | 是
1164 | 是不是
1165 | 是以
1166 | 是否
1167 | 是的
1168 | 显然
1169 | 显著
1170 | 普通
1171 | 普遍
1172 | 暗中
1173 | 暗地里
1174 | 暗自
1175 | 更
1176 | 更为
1177 | 更加
1178 | 更进一步
1179 | 曾
1180 | 曾经
1181 | 替
1182 | 替代
1183 | 最
1184 | 最后
1185 | 最大
1186 | 最好
1187 | 最後
1188 | 最近
1189 | 最高
1190 | 有
1191 | 有些
1192 | 有关
1193 | 有利
1194 | 有力
1195 | 有及
1196 | 有所
1197 | 有效
1198 | 有时
1199 | 有点
1200 | 有的
1201 | 有的是
1202 | 有着
1203 | 有著
1204 | 望
1205 | 朝
1206 | 朝着
1207 | 末##末
1208 | 本
1209 | 本人
1210 | 本地
1211 | 本着
1212 | 本身
1213 | 权时
1214 | 来
1215 | 来不及
1216 | 来得及
1217 | 来看
1218 | 来着
1219 | 来自
1220 | 来讲
1221 | 来说
1222 | 极
1223 | 极为
1224 | 极了
1225 | 极其
1226 | 极力
1227 | 极大
1228 | 极度
1229 | 极端
1230 | 构成
1231 | 果然
1232 | 果真
1233 | 某
1234 | 某个
1235 | 某些
1236 | 某某
1237 | 根据
1238 | 根本
1239 | 格外
1240 | 梆
1241 | 概
1242 | 次第
1243 | 欢迎
1244 | 欤
1245 | 正值
1246 | 正在
1247 | 正如
1248 | 正巧
1249 | 正常
1250 | 正是
1251 | 此
1252 | 此中
1253 | 此后
1254 | 此地
1255 | 此处
1256 | 此外
1257 | 此时
1258 | 此次
1259 | 此间
1260 | 殆
1261 | 毋宁
1262 | 每
1263 | 每个
1264 | 每天
1265 | 每年
1266 | 每当
1267 | 每时每刻
1268 | 每每
1269 | 每逢
1270 | 比
1271 | 比及
1272 | 比如
1273 | 比如说
1274 | 比方
1275 | 比照
1276 | 比起
1277 | 比较
1278 | 毕竟
1279 | 毫不
1280 | 毫无
1281 | 毫无例外
1282 | 毫无保留地
1283 | 汝
1284 | 沙沙
1285 | 没
1286 | 没奈何
1287 | 没有
1288 | 沿
1289 | 沿着
1290 | 注意
1291 | 活
1292 | 深入
1293 | 清楚
1294 | 满
1295 | 满足
1296 | 漫说
1297 | 焉
1298 | 然
1299 | 然则
1300 | 然后
1301 | 然後
1302 | 然而
1303 | 照
1304 | 照着
1305 | 牢牢
1306 | 特别是
1307 | 特殊
1308 | 特点
1309 | 犹且
1310 | 犹自
1311 | 独
1312 | 独自
1313 | 猛然
1314 | 猛然间
1315 | 率尔
1316 | 率然
1317 | 现代
1318 | 现在
1319 | 理应
1320 | 理当
1321 | 理该
1322 | 瑟瑟
1323 | 甚且
1324 | 甚么
1325 | 甚或
1326 | 甚而
1327 | 甚至
1328 | 甚至于
1329 | 用
1330 | 用来
1331 | 甫
1332 | 甭
1333 | 由
1334 | 由于
1335 | 由是
1336 | 由此
1337 | 由此可见
1338 | 略
1339 | 略为
1340 | 略加
1341 | 略微
1342 | 白
1343 | 白白
1344 | 的
1345 | 的确
1346 | 的话
1347 | 皆可
1348 | 目前
1349 | 直到
1350 | 直接
1351 | 相似
1352 | 相信
1353 | 相反
1354 | 相同
1355 | 相对
1356 | 相对而言
1357 | 相应
1358 | 相当
1359 | 相等
1360 | 省得
1361 | 看
1362 | 看上去
1363 | 看出
1364 | 看到
1365 | 看来
1366 | 看样子
1367 | 看看
1368 | 看见
1369 | 看起来
1370 | 真是
1371 | 真正
1372 | 眨眼
1373 | 着
1374 | 着呢
1375 | 矣
1376 | 矣乎
1377 | 矣哉
1378 | 知道
1379 | 砰
1380 | 确定
1381 | 碰巧
1382 | 社会主义
1383 | 离
1384 | 种
1385 | 积极
1386 | 移动
1387 | 究竟
1388 | 穷年累月
1389 | 突出
1390 | 突然
1391 | 窃
1392 | 立
1393 | 立刻
1394 | 立即
1395 | 立地
1396 | 立时
1397 | 立马
1398 | 竟
1399 | 竟然
1400 | 竟而
1401 | 第
1402 | 第二
1403 | 等
1404 | 等到
1405 | 等等
1406 | 策略地
1407 | 简直
1408 | 简而言之
1409 | 简言之
1410 | 管
1411 | 类如
1412 | 粗
1413 | 精光
1414 | 紧接着
1415 | 累年
1416 | 累次
1417 | 纯
1418 | 纯粹
1419 | 纵
1420 | 纵令
1421 | 纵使
1422 | 纵然
1423 | 练习
1424 | 组成
1425 | 经
1426 | 经常
1427 | 经过
1428 | 结合
1429 | 结果
1430 | 给
1431 | 绝
1432 | 绝不
1433 | 绝对
1434 | 绝非
1435 | 绝顶
1436 | 继之
1437 | 继后
1438 | 继续
1439 | 继而
1440 | 维持
1441 | 综上所述
1442 | 缕缕
1443 | 罢了
1444 | 老
1445 | 老大
1446 | 老是
1447 | 老老实实
1448 | 考虑
1449 | 者
1450 | 而
1451 | 而且
1452 | 而况
1453 | 而又
1454 | 而后
1455 | 而外
1456 | 而已
1457 | 而是
1458 | 而言
1459 | 而论
1460 | 联系
1461 | 联袂
1462 | 背地里
1463 | 背靠背
1464 | 能
1465 | 能否
1466 | 能够
1467 | 腾
1468 | 自
1469 | 自个儿
1470 | 自从
1471 | 自各儿
1472 | 自后
1473 | 自家
1474 | 自己
1475 | 自打
1476 | 自身
1477 | 臭
1478 | 至
1479 | 至于
1480 | 至今
1481 | 至若
1482 | 致
1483 | 般的
1484 | 良好
1485 | 若
1486 | 若夫
1487 | 若是
1488 | 若果
1489 | 若非
1490 | 范围
1491 | 莫
1492 | 莫不
1493 | 莫不然
1494 | 莫如
1495 | 莫若
1496 | 莫非
1497 | 获得
1498 | 藉以
1499 | 虽
1500 | 虽则
1501 | 虽然
1502 | 虽说
1503 | 蛮
1504 | 行为
1505 | 行动
1506 | 表明
1507 | 表示
1508 | 被
1509 | 要
1510 | 要不
1511 | 要不是
1512 | 要不然
1513 | 要么
1514 | 要是
1515 | 要求
1516 | 见
1517 | 规定
1518 | 觉得
1519 | 譬喻
1520 | 譬如
1521 | 认为
1522 | 认真
1523 | 认识
1524 | 让
1525 | 许多
1526 | 论
1527 | 论说
1528 | 设使
1529 | 设或
1530 | 设若
1531 | 诚如
1532 | 诚然
1533 | 话说
1534 | 该
1535 | 该当
1536 | 说明
1537 | 说来
1538 | 说说
1539 | 请勿
1540 | 诸
1541 | 诸位
1542 | 诸如
1543 | 谁
1544 | 谁人
1545 | 谁料
1546 | 谁知
1547 | 谨
1548 | 豁然
1549 | 贼死
1550 | 赖以
1551 | 赶
1552 | 赶快
1553 | 赶早不赶晚
1554 | 起
1555 | 起先
1556 | 起初
1557 | 起头
1558 | 起来
1559 | 起见
1560 | 起首
1561 | 趁
1562 | 趁便
1563 | 趁势
1564 | 趁早
1565 | 趁机
1566 | 趁热
1567 | 趁着
1568 | 越是
1569 | 距
1570 | 跟
1571 | 路经
1572 | 转动
1573 | 转变
1574 | 转贴
1575 | 轰然
1576 | 较
1577 | 较为
1578 | 较之
1579 | 较比
1580 | 边
1581 | 达到
1582 | 达旦
1583 | 迄
1584 | 迅速
1585 | 过
1586 | 过于
1587 | 过去
1588 | 过来
1589 | 运用
1590 | 近
1591 | 近几年来
1592 | 近年来
1593 | 近来
1594 | 还
1595 | 还是
1596 | 还有
1597 | 还要
1598 | 这
1599 | 这一来
1600 | 这个
1601 | 这么
1602 | 这么些
1603 | 这么样
1604 | 这么点儿
1605 | 这些
1606 | 这会儿
1607 | 这儿
1608 | 这就是说
1609 | 这时
1610 | 这样
1611 | 这次
1612 | 这点
1613 | 这种
1614 | 这般
1615 | 这边
1616 | 这里
1617 | 这麽
1618 | 进入
1619 | 进去
1620 | 进来
1621 | 进步
1622 | 进而
1623 | 进行
1624 | 连
1625 | 连同
1626 | 连声
1627 | 连日
1628 | 连日来
1629 | 连袂
1630 | 连连
1631 | 迟早
1632 | 迫于
1633 | 适应
1634 | 适当
1635 | 适用
1636 | 逐步
1637 | 逐渐
1638 | 通常
1639 | 通过
1640 | 造成
1641 | 逢
1642 | 遇到
1643 | 遭到
1644 | 遵循
1645 | 遵照
1646 | 避免
1647 | 那
1648 | 那个
1649 | 那么
1650 | 那么些
1651 | 那么样
1652 | 那些
1653 | 那会儿
1654 | 那儿
1655 | 那时
1656 | 那末
1657 | 那样
1658 | 那般
1659 | 那边
1660 | 那里
1661 | 那麽
1662 | 部分
1663 | 都
1664 | 鄙人
1665 | 采取
1666 | 里面
1667 | 重大
1668 | 重新
1669 | 重要
1670 | 鉴于
1671 | 针对
1672 | 长期以来
1673 | 长此下去
1674 | 长线
1675 | 长话短说
1676 | 问题
1677 | 间或
1678 | 防止
1679 | 阿
1680 | 附近
1681 | 陈年
1682 | 限制
1683 | 陡然
1684 | 除
1685 | 除了
1686 | 除却
1687 | 除去
1688 | 除外
1689 | 除开
1690 | 除此
1691 | 除此之外
1692 | 除此以外
1693 | 除此而外
1694 | 除非
1695 | 随
1696 | 随后
1697 | 随时
1698 | 随着
1699 | 随著
1700 | 隔夜
1701 | 隔日
1702 | 难得
1703 | 难怪
1704 | 难说
1705 | 难道
1706 | 难道说
1707 | 集中
1708 | 零
1709 | 需要
1710 | 非但
1711 | 非常
1712 | 非徒
1713 | 非得
1714 | 非特
1715 | 非独
1716 | 靠
1717 | 顶多
1718 | 顷
1719 | 顷刻
1720 | 顷刻之间
1721 | 顷刻间
1722 | 顺
1723 | 顺着
1724 | 顿时
1725 | 颇
1726 | 风雨无阻
1727 | 饱
1728 | 首先
1729 | 马上
1730 | 高低
1731 | 高兴
1732 | 默然
1733 | 默默地
1734 | 齐
1735 | ︿
1736 | !
1737 | #
1738 | $
1739 | %
1740 | &
1741 | '
1742 | (
1743 | )
1744 | )÷(1-
1745 | )、
1746 | *
1747 | +
1748 | +ξ
1749 | ++
1750 | ,
1751 | ,也
1752 | -
1753 | -β
1754 | --
1755 | -[*]-
1756 | .
1757 | /
1758 | 0
1759 | 0:2
1760 | 1
1761 | 1.
1762 | 12%
1763 | 2
1764 | 2.3%
1765 | 3
1766 | 4
1767 | 5
1768 | 5:0
1769 | 6
1770 | 7
1771 | 8
1772 | 9
1773 | :
1774 | ;
1775 | <
1776 | <±
1777 | <Δ
1778 | <λ
1779 | <φ
1780 | <<
1781 | =
1782 | =″
1783 | =☆
1784 | =(
1785 | =-
1786 | =[
1787 | ={
1788 | >
1789 | >λ
1790 | ?
1791 | @
1792 | A
1793 | LI
1794 | R.L.
1795 | ZXFITL
1796 | [
1797 | [①①]
1798 | [①②]
1799 | [①③]
1800 | [①④]
1801 | [①⑤]
1802 | [①⑥]
1803 | [①⑦]
1804 | [①⑧]
1805 | [①⑨]
1806 | [①A]
1807 | [①B]
1808 | [①C]
1809 | [①D]
1810 | [①E]
1811 | [①]
1812 | [①a]
1813 | [①c]
1814 | [①d]
1815 | [①e]
1816 | [①f]
1817 | [①g]
1818 | [①h]
1819 | [①i]
1820 | [①o]
1821 | [②
1822 | [②①]
1823 | [②②]
1824 | [②③]
1825 | [②④
1826 | [②⑤]
1827 | [②⑥]
1828 | [②⑦]
1829 | [②⑧]
1830 | [②⑩]
1831 | [②B]
1832 | [②G]
1833 | [②]
1834 | [②a]
1835 | [②b]
1836 | [②c]
1837 | [②d]
1838 | [②e]
1839 | [②f]
1840 | [②g]
1841 | [②h]
1842 | [②i]
1843 | [②j]
1844 | [③①]
1845 | [③⑩]
1846 | [③F]
1847 | [③]
1848 | [③a]
1849 | [③b]
1850 | [③c]
1851 | [③d]
1852 | [③e]
1853 | [③g]
1854 | [③h]
1855 | [④]
1856 | [④a]
1857 | [④b]
1858 | [④c]
1859 | [④d]
1860 | [④e]
1861 | [⑤]
1862 | [⑤]]
1863 | [⑤a]
1864 | [⑤b]
1865 | [⑤d]
1866 | [⑤e]
1867 | [⑤f]
1868 | [⑥]
1869 | [⑦]
1870 | [⑧]
1871 | [⑨]
1872 | [⑩]
1873 | [*]
1874 | [-
1875 | []
1876 | ]
1877 | ]∧′=[
1878 | ][
1879 | _
1880 | a]
1881 | b]
1882 | c]
1883 | e]
1884 | f]
1885 | ng昉
1886 | {
1887 | {-
1888 | |
1889 | }
1890 | }>
1891 | ~
1892 | ~±
1893 | ~+
1894 | ¥
--------------------------------------------------------------------------------
/dataSet/StopWord/user_dict.txt:
--------------------------------------------------------------------------------
1 |
2 | 慕课网 3 n
3 | 很高兴 vd
--------------------------------------------------------------------------------
/dataSet/StopWord/词性.txt:
--------------------------------------------------------------------------------
1 | Ag 形语素 形容词性语素。形容词代码为 a,语素代码g前面置以A。
2 | a 形容词 取英语形容词 adjective的第1个字母。
3 | ad 副形词 直接作状语的形容词。形容词代码 a和副词代码d并在一起。
4 | an 名形词 具有名词功能的形容词。形容词代码 a和名词代码n并在一起。
5 | b 区别词 取汉字“别”的声母。
6 | c 连词 取英语连词 conjunction的第1个字母。
7 | dg 副语素 副词性语素。副词代码为 d,语素代码g前面置以D。
8 | d 副词 取 adverb的第2个字母,因其第1个字母已用于形容词。
9 | e 叹词 取英语叹词 exclamation的第1个字母。
10 | f 方位词 取汉字“方”
11 | g 语素 绝大多数语素都能作为合成词的“词根”,取汉字“根”的声母。
12 | h 前接成分 取英语 head的第1个字母。
13 | i 成语 取英语成语 idiom的第1个字母。
14 | j 简称略语 取汉字“简”的声母。
15 | k 后接成分
16 | l 习用语 习用语尚未成为成语,有点“临时性”,取“临”的声母。
17 | m 数词 取英语 numeral的第3个字母,n,u已有他用。
18 | Ng 名语素 名词性语素。名词代码为 n,语素代码g前面置以N。
19 | n 名词 取英语名词 noun的第1个字母。
20 | nr 人名 名词代码 n和“人(ren)”的声母并在一起。
21 | ns 地名 名词代码 n和处所词代码s并在一起。
22 | nt 机构团体 “团”的声母为 t,名词代码n和t并在一起。
23 | nz 其他专名 “专”的声母的第 1个字母为z,名词代码n和z并在一起。
24 | o 拟声词 取英语拟声词 onomatopoeia的第1个字母。
25 | p 介词 取英语介词 prepositional的第1个字母。
26 | q 量词 取英语 quantity的第1个字母。
27 | r 代词 取英语代词 pronoun的第2个字母,因p已用于介词。
28 | s 处所词 取英语 space的第1个字母。
29 | tg 时语素 时间词性语素。时间词代码为 t,在语素的代码g前面置以T。
30 | t 时间词 取英语 time的第1个字母。
31 | u 助词 取英语助词 auxiliary
32 | vg 动语素 动词性语素。动词代码为 v。在语素的代码g前面置以V。
33 | v 动词 取英语动词 verb的第一个字母。
34 | vd 副动词 直接作状语的动词。动词和副词的代码并在一起。
35 | vn 名动词 指具有名词功能的动词。动词和名词的代码并在一起。
36 | w 标点符号
37 | x 非语素字 非语素字只是一个符号,字母 x通常用于代表未知数、符号。
38 | y 语气词 取汉字“语”的声母。
39 | z 状态词 取汉字“状”的声母的前一个字母。
40 | un 未知词 不可识别词及用户自定义词组。取英文Unkonwn首两个字母。
--------------------------------------------------------------------------------
/dataSet/files/dataset.data:
--------------------------------------------------------------------------------
1 | NaN 8.326976 0.953952 3
2 | 14488 7.153469 1.673904 2
3 | 26052 NaN 0.805124 1
4 | 75136 13.147394 0.428964 1
5 | 38344 1.669788 0.134296 1
6 | 72993 NaN 1.032955 1
7 | 35948 6.830792 1.213192 3
8 | 42666 13.276369 NaN 3
9 | 67497 NaN NaN 1
10 | 35483 12.273169 1.508053 3
11 | 50242 3.723498 0.831917 1
12 | 63275 8.385879 1.669485 1
13 | 5569 4.875435 0.728658 2
14 | 6808 1.364838 0.640103 2
15 | 41611 0.230453 1.151996 1
16 | 36661 11.865402 0.882810 3
17 | 43605 0.120460 1.352013 1
18 | 15360 8.545204 1.340429 3
19 | 63796 5.856649 0.160006 1
20 | 10743 9.665618 0.778626 2
21 | 70808 9.778763 1.084103 1
22 | 72011 4.932976 0.632026 1
23 | 5914 2.216246 0.587095 2
24 | 14851 14.305636 0.632317 3
25 | 33553 12.591889 0.686581 3
26 | 44952 3.424649 1.004504 1
27 | 17934 0.000000 0.147573 2
28 | 27738 8.533823 0.205324 3
29 | 29290 9.829528 0.238620 3
30 | 42330 11.492186 0.263499 3
31 | 36429 3.570968 0.832254 1
32 | 39623 1.771228 0.207612 1
33 | 32404 3.513921 0.991854 1
34 | 27268 4.398172 0.975024 1
35 | 5477 4.276823 1.174874 2
36 | 14254 5.946014 1.614244 2
37 | 68613 13.798970 0.724375 1
38 | 41539 10.393591 1.663724 3
39 | 7917 3.007577 0.297302 2
40 | 21331 1.031938 0.486174 2
41 | 8338 4.751212 0.064693 2
42 | 5176 3.692269 1.655113 2
43 | 18983 10.448091 0.267652 3
44 | 68837 10.585786 0.329557 1
45 | 13438 1.604501 0.069064 2
46 | 48849 3.679497 0.961466 1
47 | 12285 3.795146 0.696694 2
48 | 7826 2.531885 1.659173 2
49 | 38768 5.308409 0.030683 3
50 | 4933 1.841792 0.028099 2
51 | 32311 2.261978 1.605603 1
52 | 26501 11.573696 1.061347 3
53 | 37433 8.038764 1.083910 3
54 | 23503 10.734007 0.103715 3
55 | 68607 9.661909 0.350772 1
56 | 27742 9.005850 0.548737 3
57 | 11303 0.000000 0.539131 2
58 | 0 5.757140 1.062373 2
59 | 32729 9.164656 1.624565 3
60 | 24619 1.318340 1.436243 1
61 | 42414 14.075597 0.695934 3
62 | 20210 10.107550 1.308398 3
63 | 33225 7.960293 1.219760 3
64 | 54483 6.317292 0.018209 1
65 | 18475 12.664194 0.595653 3
66 | 33926 2.906644 0.581657 1
67 | 43865 2.388241 0.913938 1
68 | 26547 6.024471 0.486215 3
69 | 44404 7.226764 1.255329 3
70 | 16674 4.183997 1.275290 2
71 | 8123 11.850211 1.096981 3
72 | 42747 11.661797 1.167935 3
73 | 40409 12.393001 1.571281 3
74 | 13605 9.627613 0.935842 2
75 | 26400 11.130453 0.597610 3
76 | 13491 8.842595 0.349768 3
77 | 30232 10.690010 1.456595 3
78 | 43253 5.714718 1.674780 3
79 | 55536 3.052505 1.335804 1
80 | 8807 0.000000 0.059025 2
81 | 25783 9.945307 1.287952 3
82 | 22812 2.719723 1.142148 1
83 | 77826 11.154055 1.608486 1
84 | 38172 2.687918 0.660836 1
85 | 31676 10.037847 0.962245 3
86 | 74038 12.404762 1.112080 1
87 | 44738 10.237305 0.633422 3
88 | 17410 4.745392 0.662520 2
89 | 5688 4.639461 1.569431 2
90 | 36642 3.149310 0.639669 1
91 | 29956 13.406875 1.639194 3
92 | 60350 6.068668 0.881241 1
93 | 23758 9.477022 0.899002 3
94 | 25780 3.897620 0.560201 2
95 | 11342 5.463615 1.203677 2
96 | 36109 3.369267 1.575043 1
97 | 14292 5.234562 0.825954 2
98 | 11160 0.000000 0.722170 2
99 | 23762 12.979069 0.504068 3
100 | 39567 5.376564 0.557476 1
101 | 25647 13.527910 1.586732 3
102 | 14814 2.196889 0.784587 2
103 | 73590 10.691748 0.007509 1
104 | 35187 1.659242 0.447066 1
105 | 49459 8.369667 0.656697 3
106 | 31657 13.157197 0.143248 3
107 | 6259 8.199667 0.908508 2
108 | 33101 4.441669 0.439381 3
109 | 27107 9.846492 0.644523 3
110 | 17824 0.019540 0.977949 2
111 | 43536 8.253774 0.748700 3
112 | 67705 6.038620 1.509646 1
113 | 35283 6.091587 1.694641 3
114 | 71308 8.986820 1.225165 1
115 | 31054 11.508473 1.624296 3
116 | 52387 8.807734 0.713922 3
117 | 40328 0.000000 0.816676 1
118 | 34844 NaN 1.665414 3
119 | 11607 3.178117 0.542752 2
120 | 64306 7.013795 0.139909 1
121 | 32721 9.605014 0.065254 3
122 | 33170 1.230540 1.331674 1
123 | 37192 10.412811 0.890803 3
124 | 13089 0.000000 0.567161 2
125 | 66491 9.699991 0.122011 1
126 | 15941 0.000000 0.061191 2
127 | 4272 4.455293 0.272135 2
128 | 48812 3.020977 1.502803 1
129 | 28818 8.099278 0.216317 3
130 | 35394 1.157764 1.603217 1
131 | 71791 10.105396 0.121067 1
132 | 40668 11.230148 0.408603 3
133 | 39580 9.070058 0.011379 3
134 | 11786 0.566460 0.478837 2
135 | 19251 0.000000 0.487300 2
136 | 56594 8.956369 1.193484 3
137 | 54495 1.523057 0.620528 1
138 | 11844 2.749006 0.169855 2
139 | 45465 9.235393 0.188350 3
140 | 31033 10.555573 0.403927 3
141 | 16633 6.956372 1.519308 2
142 | 13887 0.636281 1.273984 2
143 | 52603 3.574737 0.075163 1
--------------------------------------------------------------------------------
/dataSet/files/dataset.txt:
--------------------------------------------------------------------------------
1 | 40920 8.326976 0.953952 3
2 | 14488 7.153469 1.673904 2
3 | 26052 1.441871 0.805124 1
4 | 75136 13.147394 0.428964 1
5 | 38344 1.669788 0.134296 1
6 | 72993 10.141740 1.032955 1
7 | 35948 6.830792 1.213192 3
8 | 42666 13.276369 0.543880 3
9 | 67497 8.631577 0.749278 1
10 | 35483 12.273169 1.508053 3
11 | 50242 3.723498 0.831917 1
12 | 63275 8.385879 1.669485 1
13 | 5569 4.875435 0.728658 2
14 | 6808 1.364838 0.640103 2
15 | 41611 0.230453 1.151996 1
16 | 36661 11.865402 0.882810 3
17 | 43605 0.120460 1.352013 1
18 | 15360 8.545204 1.340429 3
19 | 63796 5.856649 0.160006 1
20 | 10743 9.665618 0.778626 2
21 | 70808 9.778763 1.084103 1
22 | 72011 4.932976 0.632026 1
23 | 5914 2.216246 0.587095 2
24 | 14851 14.305636 0.632317 3
25 | 33553 12.591889 0.686581 3
26 | 44952 3.424649 1.004504 1
27 | 17934 0.000000 0.147573 2
28 | 27738 8.533823 0.205324 3
29 | 29290 9.829528 0.238620 3
30 | 42330 11.492186 0.263499 3
31 | 36429 3.570968 0.832254 1
32 | 39623 1.771228 0.207612 1
33 | 32404 3.513921 0.991854 1
34 | 27268 4.398172 0.975024 1
35 | 5477 4.276823 1.174874 2
36 | 14254 5.946014 1.614244 2
37 | 68613 13.798970 0.724375 1
38 | 41539 10.393591 1.663724 3
39 | 7917 3.007577 0.297302 2
40 | 21331 1.031938 0.486174 2
41 | 8338 4.751212 0.064693 2
42 | 5176 3.692269 1.655113 2
43 | 18983 10.448091 0.267652 3
44 | 68837 10.585786 0.329557 1
45 | 13438 1.604501 0.069064 2
46 | 48849 3.679497 0.961466 1
47 | 12285 3.795146 0.696694 2
48 | 7826 2.531885 1.659173 2
49 | 38768 5.308409 0.030683 3
50 | 4933 1.841792 0.028099 2
51 | 32311 2.261978 1.605603 1
52 | 26501 11.573696 1.061347 3
53 | 37433 8.038764 1.083910 3
54 | 23503 10.734007 0.103715 3
55 | 68607 9.661909 0.350772 1
56 | 27742 9.005850 0.548737 3
57 | 11303 0.000000 0.539131 2
58 | 0 5.757140 1.062373 2
59 | 32729 9.164656 1.624565 3
60 | 24619 1.318340 1.436243 1
61 | 42414 14.075597 0.695934 3
62 | 20210 10.107550 1.308398 3
63 | 33225 7.960293 1.219760 3
64 | 54483 6.317292 0.018209 1
65 | 18475 12.664194 0.595653 3
66 | 33926 2.906644 0.581657 1
67 | 43865 2.388241 0.913938 1
68 | 26547 6.024471 0.486215 3
69 | 44404 7.226764 1.255329 3
70 | 16674 4.183997 1.275290 2
71 | 8123 11.850211 1.096981 3
72 | 42747 11.661797 1.167935 3
73 | 40409 12.393001 1.571281 3
74 | 13605 9.627613 0.935842 2
75 | 26400 11.130453 0.597610 3
76 | 13491 8.842595 0.349768 3
77 | 30232 10.690010 1.456595 3
78 | 43253 5.714718 1.674780 3
79 | 55536 3.052505 1.335804 1
80 | 8807 0.000000 0.059025 2
81 | 25783 9.945307 1.287952 3
82 | 22812 2.719723 1.142148 1
83 | 77826 11.154055 1.608486 1
84 | 38172 2.687918 0.660836 1
85 | 31676 10.037847 0.962245 3
86 | 74038 12.404762 1.112080 1
87 | 44738 10.237305 0.633422 3
88 | 17410 4.745392 0.662520 2
89 | 5688 4.639461 1.569431 2
90 | 36642 3.149310 0.639669 1
91 | 29956 13.406875 1.639194 3
92 | 60350 6.068668 0.881241 1
93 | 23758 9.477022 0.899002 3
94 | 25780 3.897620 0.560201 2
95 | 11342 5.463615 1.203677 2
96 | 36109 3.369267 1.575043 1
97 | 14292 5.234562 0.825954 2
98 | 11160 0.000000 0.722170 2
99 | 23762 12.979069 0.504068 3
100 | 39567 5.376564 0.557476 1
101 | 25647 13.527910 1.586732 3
102 | 14814 2.196889 0.784587 2
103 | 73590 10.691748 0.007509 1
104 | 35187 1.659242 0.447066 1
105 | 49459 8.369667 0.656697 3
106 | 31657 13.157197 0.143248 3
107 | 6259 8.199667 0.908508 2
108 | 33101 4.441669 0.439381 3
109 | 27107 9.846492 0.644523 3
110 | 17824 0.019540 0.977949 2
111 | 43536 8.253774 0.748700 3
112 | 67705 6.038620 1.509646 1
113 | 35283 6.091587 1.694641 3
114 | 71308 8.986820 1.225165 1
115 | 31054 11.508473 1.624296 3
116 | 52387 8.807734 0.713922 3
117 | 40328 0.000000 0.816676 1
118 | 34844 NaN 1.665414 3
119 | 11607 3.178117 0.542752 2
120 | 64306 7.013795 0.139909 1
121 | 32721 9.605014 0.065254 3
122 | 33170 1.230540 1.331674 1
123 | 37192 10.412811 0.890803 3
124 | 13089 0.000000 0.567161 2
125 | 66491 9.699991 0.122011 1
126 | 15941 0.000000 0.061191 2
127 | 4272 4.455293 0.272135 2
128 | 48812 3.020977 1.502803 1
129 | 28818 8.099278 0.216317 3
130 | 35394 1.157764 1.603217 1
131 | 71791 10.105396 0.121067 1
132 | 40668 11.230148 0.408603 3
133 | 39580 9.070058 0.011379 3
134 | 11786 0.566460 0.478837 2
135 | 19251 0.000000 0.487300 2
136 | 56594 8.956369 1.193484 3
137 | 54495 1.523057 0.620528 1
138 | 11844 2.749006 0.169855 2
139 | 45465 9.235393 0.188350 3
140 | 31033 10.555573 0.403927 3
141 | 16633 6.956372 1.519308 2
142 | 13887 0.636281 1.273984 2
143 | 52603 3.574737 0.075163 1
--------------------------------------------------------------------------------
/dataSet/files/mycorpus.dict:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/files/mycorpus.dict
--------------------------------------------------------------------------------
/dataSet/files/mycorpus.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 0 北京 2
3 | 1 新浪 2
4 | 2 消息 2
5 |
--------------------------------------------------------------------------------
/dataSet/files/newsdata.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bainingchao/DataProcess/54f33677d9971a35f26aaaae21dce0f7a737d575/dataSet/files/newsdata.txt
--------------------------------------------------------------------------------