forked from lzjun567/python_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
刘志军
committed
Jan 14, 2019
1 parent
372b0e3
commit b9d4a0d
Showing
3 changed files
with
5,276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding:utf-8 -*- | ||
import pkuseg | ||
from collections import Counter | ||
import pprint | ||
|
||
content = [] | ||
with open("yanjiang.txt", encoding="utf-8") as f: | ||
content = f.read() | ||
|
||
lexicon = ['小程序', '朋友圈', '公众号'] # | ||
seg = pkuseg.pkuseg(user_dict=lexicon) # 加载模型,给定用户词典 | ||
text = seg.cut(content) | ||
|
||
stopwords = [] | ||
|
||
with open("stopword.txt", encoding="utf-8") as f: | ||
stopwords = f.read() | ||
|
||
new_text = [] | ||
|
||
for w in text: | ||
if w not in stopwords: | ||
new_text.append(w) | ||
|
||
counter = Counter(new_text) | ||
pprint.pprint(counter.most_common(50)) |
Oops, something went wrong.