parent
77def82c3b
commit
0e6304b6fd
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 505 KiB |
After Width: | Height: | Size: 145 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 80 KiB |
@ -0,0 +1,24 @@
|
||||
from operator import itemgetter
|
||||
import jieba
|
||||
import string
|
||||
|
||||
|
||||
# 统计词汇数
|
||||
def count_word(filename):
|
||||
file_txt = open(filename, "r", encoding='utf-8').read()
|
||||
file_txt = file_txt.lower() # 将文本文件内容的大写字母换成小写字母
|
||||
|
||||
for ch in string.punctuation: # 将文本中的特殊字符替换为空格
|
||||
file_txt = file_txt.replace(ch, " ")
|
||||
|
||||
words = list(jieba.lcut(file_txt, cut_all=False)) # 分词
|
||||
counts = {} # 用于统计词汇数的字典
|
||||
|
||||
for i in set(words): # 统计词汇数
|
||||
if len(i) > 1:
|
||||
counts[i] = words.count(i)
|
||||
|
||||
counts = sorted(counts.items(), key=itemgetter(1), reverse=True) # 按字典元素的值进行逆序排序
|
||||
for i in range(20): # 输出词汇数最多的10个词
|
||||
print(counts[i])
|
||||
return counts
|
@ -0,0 +1,42 @@
|
||||
import matplotlib.pyplot as plt
|
||||
from wordcloud import WordCloud
|
||||
from imageio import imread
|
||||
from scanfiles import scan_files
|
||||
import csv
|
||||
|
||||
|
||||
def create_cloud(dic):
|
||||
# 将内容写入temp.txt
|
||||
with open('temp.txt', 'w', encoding='utf-8') as f:
|
||||
for i in dic:
|
||||
f.write(("%s " % i[0]) * i[1] + "\n")
|
||||
temp_txt = open("temp.txt", "r", encoding='utf-8').read()
|
||||
filepath = 'cloudshape'
|
||||
scan_files(filepath) # 扫描词云图背景图文件
|
||||
cloudshape = filepath + '\\' + "bird.jpg" # 默认背景图片
|
||||
|
||||
# 选择词云图背景文件的序号
|
||||
picture_no = input("Please select a background by the number in range:")
|
||||
with open('filename.csv', 'r', encoding='utf-8') as csvfile:
|
||||
reader = csv.reader(csvfile)
|
||||
for i in reader:
|
||||
if picture_no == i[0]:
|
||||
print('You choose cloud shape:', i[1], end='\n')
|
||||
cloudshape = filepath + '\\' + i[1]
|
||||
if cloudshape == filepath + '\\' + "bird.jpg": # 判断是否成功选择词云形状
|
||||
print('Input error,use default cloud shape bird.jpg', end='\n')
|
||||
|
||||
color_mask = imread(cloudshape) # 词云形状图设置
|
||||
|
||||
# 词云参数设置
|
||||
cloud = WordCloud(
|
||||
font_path='fonts\\sim-sun.ttc', # 字体必须设置
|
||||
background_color='white', # 词云图像的背景色,默认为黑色
|
||||
mask=color_mask, # 绘制模板
|
||||
max_words=200, # 最大显示单词字数
|
||||
max_font_size=200, # 最大单词的字体大小,若无设置,则使用画布的大小
|
||||
)
|
||||
word_cloud = cloud.generate(temp_txt)
|
||||
plt.imshow(word_cloud)
|
||||
plt.axis('off')
|
||||
plt.show()
|
|
@ -0,0 +1,11 @@
|
||||
Wherever you are, and whoever you may be, there is one thing in which you and I are just alike at this moment, all in all
|
||||
the moments of our existence. We are not at rest; we are on a journey. Our life is a movement, a tendency, a steady, ceaseless progress towards an unseen goal. We are gaining something, or losing something, every day.
|
||||
Even when our position and our character seem to remain precisely the same, they are changing, for the mere advance of time is a change. It is not the same thing to have a bare field in January and in July. The season makes the difference.
|
||||
The limitations that are childlike in the child are childish in the man.
|
||||
Everything that we do is a step in one direction or another. Even the failure to do something is in itself a deed.
|
||||
It sets us forward or backward. The action of the negative pole of a magnetic needle is just as real as the action of the positive pole.
|
||||
To decline is to accept the other alternative. .
|
||||
Are you nearer to your port today than you were yesterday? Yes, you must be a little nearer to some port or other;
|
||||
for since your ship was launched upon the sea of life, you have never been still for a single moment - the sea is too deep;
|
||||
you could not find an anchorage if you would; there can be no pause until you come into port.
|
||||
|
@ -0,0 +1,20 @@
|
||||
洛神赋
|
||||
【作者】曹植 【朝代】魏晋
|
||||
|
||||
黄初三年,余朝京师,还济洛川。古人有言,斯水之神,名曰宓妃。感宋玉对楚王神女之事,遂作斯赋。其辞曰:
|
||||
|
||||
余从京域,言归东藩。背伊阙,越轘辕,经通谷,陵景山。日既西倾,车殆马烦。尔乃税驾乎蘅皋,秣驷乎芝田,容与乎阳林,流眄乎洛川。于是精移神骇,忽焉思散。俯则未察,仰以殊观,睹一丽人,于岩之畔。乃援御者而告之曰:“尔有觌于彼者乎?彼何人斯?若此之艳也!”御者对曰:“臣闻河洛之神,名曰宓妃。然则君王之所见也,无乃是乎?其状若何?臣愿闻之。”
|
||||
|
||||
余告之曰:“其形也,翩若惊鸿,婉若游龙。荣曜秋菊,华茂春松。髣髴兮若轻云之蔽月,飘飖兮若流风之回雪。远而望之,皎若太阳升朝霞;迫而察之,灼若芙蕖出渌波。秾纤得衷,修短合度。肩若削成,腰如约素。延颈秀项,皓质呈露。芳泽无加,铅华弗御。云髻峨峨,修眉联娟。丹唇外朗,皓齿内鲜,明眸善睐,靥辅承权。瑰姿艳逸,仪静体闲。柔情绰态,媚于语言。奇服旷世,骨像应图。披罗衣之璀粲兮,珥瑶碧之华琚。戴金翠之首饰,缀明珠以耀躯。践远游之文履,曳雾绡之轻裾。微幽兰之芳蔼兮,步踟蹰于山隅。
|
||||
|
||||
于是忽焉纵体,以遨以嬉。左倚采旄,右荫桂旗。攘皓腕于神浒兮,采湍濑之玄芝。余情悦其淑美兮,心振荡而不怡。无良媒以接欢兮,托微波而通辞。愿诚素之先达兮,解玉佩以要之。嗟佳人之信修兮,羌习礼而明诗。抗琼珶以和予兮,指潜渊而为期。执眷眷之款实兮,惧斯灵之我欺。感交甫之弃言兮,怅犹豫而狐疑。收和颜而静志兮,申礼防以自持。
|
||||
|
||||
于是洛灵感焉,徙倚彷徨,神光离合,乍阴乍阳。竦轻躯以鹤立,若将飞而未翔。践椒涂之郁烈,步蘅薄而流芳。超长吟以永慕兮,声哀厉而弥长。
|
||||
|
||||
尔乃众灵杂沓,命俦啸侣,或戏清流,或翔神渚,或采明珠,或拾翠羽。从南湘之二妃,携汉滨之游女。叹匏瓜之无匹兮,咏牵牛之独处。扬轻袿之猗靡兮,翳修袖以延伫。体迅飞凫,飘忽若神,凌波微步,罗袜生尘。动无常则,若危若安。进止难期,若往若还。转眄流精,光润玉颜。含辞未吐,气若幽兰。华容婀娜,令我忘餐。
|
||||
|
||||
于是屏翳收风,川后静波。冯夷鸣鼓,女娲清歌。腾文鱼以警乘,鸣玉鸾以偕逝。六龙俨其齐首,载云车之容裔,鲸鲵踊而夹毂,水禽翔而为卫。
|
||||
|
||||
于是越北沚。过南冈,纡素领,回清阳,动朱唇以徐言,陈交接之大纲。恨人神之道殊兮,怨盛年之莫当。抗罗袂以掩涕兮,泪流襟之浪浪。悼良会之永绝兮,哀一逝而异乡。无微情以效爱兮,献江南之明珰。虽潜处于太阴,长寄心于君王。忽不悟其所舍,怅神宵而蔽光。
|
||||
|
||||
于是背下陵高,足往神留,遗情想像,顾望怀愁。冀灵体之复形,御轻舟而上溯。浮长川而忘返,思绵绵而增慕。夜耿耿而不寐,沾繁霜而至曙。命仆夫而就驾,吾将归乎东路。揽騑辔以抗策,怅盘桓而不能去。
|
@ -0,0 +1,49 @@
|
||||
《背影》
|
||||
朱自清
|
||||
|
||||
我与父亲不相见已二年余了,我最不能忘记的是他的背影。
|
||||
|
||||
那年冬天,祖母死了,父亲的差使也交卸了,正是祸不单行的日子。我从北京到徐州,打算跟着父亲奔丧回家。到徐州见着父亲,看见满院狼藉的东西,又想起祖母,不禁簌簌地流下眼泪。
|
||||
|
||||
父亲说“事已如此,不必难过,好在天无绝人之路!”
|
||||
|
||||
回家变卖典质,父亲还了亏空;又借钱办了丧事。这些日子,家中光景很惨淡,一半为了丧事,一半为了父亲赋闲。丧事完毕,父亲要到南京谋事,我也要回北京念书,我们便同行。
|
||||
|
||||
|
||||
|
||||
到南京时,有朋友约去游逛,勾留了一日;第二日上午便须渡江到浦口,下午上车北去。
|
||||
|
||||
父亲因为事忙,本已说定不送我,叫旅馆里一个熟识的茶房陪我同去。他再三嘱咐茶房,甚是仔细。但他终于不放心,怕茶房不妥帖;颇踌躇了一会。其实我那年已二十岁,北京已来往过两三次,是没有什么要紧的了。他踌躇了一会,终于决定还是自己送我去。我再三回劝他不必去;他只说,“不要紧,他们去不好!”
|
||||
|
||||
我们过了江,进了车站。我买票,他忙着照看行李。行李太多了,得向脚夫行些小费才可过去。他便又忙着和他们讲价钱。我那时真是聪明过分,总觉他说话不大漂亮,非自己插嘴不可,但他终于讲定了价钱,就送我上车。
|
||||
|
||||
|
||||
|
||||
他给我拣定了靠车门的一张椅子;我将他给我做的紫毛大衣铺好座位。他嘱我路上小心,夜里要警醒些,不要受凉。又嘱托茶房好好照应我。我心里暗笑他的愚;他们只认得钱,托他们只是白托!而且我这样大年纪的人,难道还不能料理自己么?唉,我现在想想,那时真是太聪明了!
|
||||
|
||||
我说道,“爸爸,你走吧。”
|
||||
|
||||
他往车外看了看说,“我买几个橘子去。你就在此地,不要走动。”
|
||||
|
||||
我看那边月台的栅栏外有几个卖东西的等着顾客。走到那边月台,须穿过铁道,须跳下去又爬上去。父亲是一个胖子,走过去自然要费事些。我本来要去的,他不肯,只好让他去。
|
||||
|
||||
|
||||
我看见他戴着黑布小帽,穿着黑布大马褂,深青布棉袍,蹒跚地走到铁道边,慢慢探身下去,尚不大难。可是他穿过铁道,要爬上那边月台,就不容易了。他用两手攀着上面,两脚再向上缩;他肥胖的身子向左微倾,显出努力的样子。这时我看见他的背影,我的泪很快地流下来了。我赶紧拭干了泪。怕他看见,也怕别人看见。
|
||||
|
||||
我再向外看时,他已抱了朱红的橘子往回走了。过铁道时,他先将橘子散放在地上,自己慢慢爬下,再抱起橘子走。到这边时,我赶紧去搀他。他和我走到车上,将橘子一股脑儿放在我的皮大衣上。于是扑扑衣上的泥土,心里很轻松似的。
|
||||
|
||||
过一会儿说,“我走了,到那边来信!”我望着他走出去。
|
||||
|
||||
他走了几步,回过头看见我,说,“进去吧,里边没人。”
|
||||
|
||||
等他的背影混入来来往往的人里,再找不着了,我便进来坐下,我的眼泪又来了。
|
||||
|
||||
|
||||
|
||||
近几年来,父亲和我都是东奔西走,家中光景是一日不如一日。他少年出外谋生,独力支持,做了许多大事。哪知老境却如此颓唐!
|
||||
|
||||
他触目伤怀,自然情不能自已。情郁于中,自然要发之于外;家庭琐屑便往往触他之怒。他待我渐渐不同往日。但最近两年不见,他终于忘却我的不好,只是惦记着我,惦记着我的儿子。
|
||||
|
||||
我北来后,他写了一信给我,信中说道:“我身体平安,唯膀子疼痛厉害,举箸提笔,诸多不便,大约大去之期不远矣。”
|
||||
|
||||
我读到此处,在晶莹的泪光中,又看见那肥胖的、青布棉袍黑布马褂的背影。
|
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
from countword import count_word
|
||||
from createcloud import create_cloud
|
||||
from scanfiles import scan_files
|
||||
import csv
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
filepath = 'files' # txt 文本存放路径
|
||||
scan_files(filepath)
|
||||
file_no = input("Please select a file by the number in range:")
|
||||
while file_no != 'E':
|
||||
if not file_no.isnumeric(): # 判断是否是数字
|
||||
print("Input error!")
|
||||
file_no = input("Please reselect a file by the number in range:")
|
||||
else: # 读取序号对应的文件名
|
||||
with open('filename.csv', 'r', encoding='utf-8') as csvfile:
|
||||
reader = csv.reader(csvfile)
|
||||
for i in reader:
|
||||
if file_no == i[0]:
|
||||
print('Your choice:', i[1], end='\n')
|
||||
filename = filepath + '\\' + i[1]
|
||||
create_cloud(count_word(filename))
|
||||
scan_files(filepath)
|
||||
else: # 判断file_no是否在范围内
|
||||
file_no = input("Please select a file by the number in range:")
|
@ -0,0 +1,28 @@
|
||||
import csv
|
||||
import os
|
||||
|
||||
|
||||
# 寻找程序所在目录下的所有文本文件,并打印文件名
|
||||
def scan_files(filepath): # 传入当前绝对路径及指定字符串
|
||||
|
||||
# 用于清空filename.csv'内容
|
||||
with open('filename.csv', 'w', encoding='utf-8', newline='') as file_handler:
|
||||
file_writer = csv.writer(file_handler)
|
||||
row = ['file_no', 'filename']
|
||||
file_writer.writerow(row)
|
||||
|
||||
files = os.listdir(filepath)
|
||||
file_no = 0
|
||||
# 遍历所有文件
|
||||
print('files list:')
|
||||
for filename in files:
|
||||
file_no = file_no + 1
|
||||
print('%d--' % file_no, end='')
|
||||
print(filename)
|
||||
|
||||
# 保存文件名到filename.csv'
|
||||
with open('filename.csv', 'a+', encoding='utf-8', newline='') as file_handler:
|
||||
file_writer = csv.writer(file_handler)
|
||||
row = [file_no, filename]
|
||||
file_writer.writerow(row)
|
||||
return file_no
|
@ -0,0 +1,292 @@
|
||||
于是 于是 于是 于是 于是 于是
|
||||
宓妃 宓妃
|
||||
忽焉 忽焉
|
||||
明珠 明珠
|
||||
君王 君王
|
||||
幽兰 幽兰
|
||||
御者 御者
|
||||
洛川 洛川
|
||||
名曰 名曰
|
||||
罗袜
|
||||
之所见
|
||||
神女
|
||||
或戏
|
||||
修袖
|
||||
自持
|
||||
阳林
|
||||
云髻
|
||||
从京域
|
||||
以和予
|
||||
拾翠羽
|
||||
而告
|
||||
语言
|
||||
流风
|
||||
骨像
|
||||
披罗衣
|
||||
如约
|
||||
精移
|
||||
清歌
|
||||
秾纤
|
||||
想像
|
||||
难期
|
||||
作者
|
||||
或采
|
||||
以耀躯
|
||||
不怡
|
||||
进止
|
||||
抗罗袂
|
||||
忽不悟
|
||||
啸侣
|
||||
于岩
|
||||
之二
|
||||
神留
|
||||
之游
|
||||
乃援
|
||||
繁霜
|
||||
飘忽
|
||||
怀愁
|
||||
或翔
|
||||
翩若惊鸿
|
||||
清流
|
||||
流芳
|
||||
礼而明
|
||||
弗御
|
||||
以警
|
||||
含辞
|
||||
静波
|
||||
川后
|
||||
灵感
|
||||
余情
|
||||
以效
|
||||
凌波微
|
||||
泪流
|
||||
荣曜秋菊
|
||||
之永绝
|
||||
哀一逝
|
||||
神浒兮
|
||||
俯则
|
||||
合度
|
||||
步蘅薄
|
||||
为期
|
||||
无加
|
||||
楚王
|
||||
鸣玉鸾
|
||||
冀灵体
|
||||
余朝
|
||||
太阳升
|
||||
以延
|
||||
超长
|
||||
鲸鲵
|
||||
上溯
|
||||
怅神宵
|
||||
轻舟
|
||||
作斯赋
|
||||
静志
|
||||
踟蹰
|
||||
有言
|
||||
叹匏瓜
|
||||
迫而察
|
||||
京师
|
||||
驾乎蘅皋
|
||||
攘皓腕
|
||||
左倚
|
||||
若此
|
||||
然则
|
||||
何人
|
||||
魏晋
|
||||
申礼
|
||||
玉颜
|
||||
盘桓
|
||||
其所舍
|
||||
修眉联娟
|
||||
光润
|
||||
齐首
|
||||
增慕
|
||||
浪浪
|
||||
过南冈
|
||||
呈露
|
||||
瑶碧之华
|
||||
鸣鼓
|
||||
臣闻
|
||||
柔情绰态
|
||||
媚于
|
||||
洛神赋
|
||||
应图
|
||||
绵绵
|
||||
鹤立
|
||||
羌习
|
||||
斯水
|
||||
艳逸
|
||||
其形
|
||||
肩若
|
||||
离合
|
||||
为卫
|
||||
明眸
|
||||
未翔
|
||||
之文履
|
||||
异乡
|
||||
之神
|
||||
交接
|
||||
感交甫
|
||||
神光
|
||||
处于
|
||||
延颈秀项
|
||||
无常
|
||||
之猗靡
|
||||
辅承权
|
||||
景山
|
||||
铅华
|
||||
仰以
|
||||
纵体
|
||||
之无匹
|
||||
忘餐
|
||||
神骇
|
||||
之容裔
|
||||
独处
|
||||
复形
|
||||
背伊阙
|
||||
指潜渊
|
||||
惧斯灵
|
||||
无良
|
||||
感宋玉
|
||||
徐言
|
||||
扬轻
|
||||
不能
|
||||
虽潜
|
||||
轻躯
|
||||
河洛之
|
||||
三年
|
||||
尔乃众
|
||||
耿耿
|
||||
修兮
|
||||
冯夷
|
||||
首饰
|
||||
华容
|
||||
东路
|
||||
以永慕
|
||||
抗策
|
||||
践椒涂
|
||||
之芳蔼
|
||||
掩涕
|
||||
戴金翠
|
||||
其状
|
||||
未察
|
||||
流精
|
||||
旷世
|
||||
峨峨
|
||||
收和颜
|
||||
蔽光
|
||||
殊观
|
||||
危若安
|
||||
芳泽
|
||||
载云车
|
||||
接欢
|
||||
思散
|
||||
出渌波
|
||||
曳雾
|
||||
其辞
|
||||
先达
|
||||
犹豫
|
||||
通谷
|
||||
携汉滨
|
||||
皓齿
|
||||
媒以
|
||||
杂沓
|
||||
车殆马烦
|
||||
婉若游龙
|
||||
腾文鱼
|
||||
朝代
|
||||
还济
|
||||
女娲
|
||||
越北
|
||||
削成
|
||||
无微情
|
||||
远游
|
||||
命仆夫
|
||||
素领
|
||||
尔乃税
|
||||
容与乎
|
||||
于山隅
|
||||
大纲
|
||||
之艳
|
||||
足往
|
||||
厉而弥长
|
||||
曹植
|
||||
余告
|
||||
玉佩
|
||||
之莫当
|
||||
芝田
|
||||
不寐
|
||||
皓质
|
||||
防以
|
||||
丽人
|
||||
西倾
|
||||
微波
|
||||
长寄心
|
||||
秣驷乎
|
||||
婀娜
|
||||
清阳
|
||||
气若
|
||||
六龙
|
||||
瑰姿
|
||||
仪静体闲
|
||||
之道殊
|
||||
内鲜
|
||||
归乎
|
||||
体迅
|
||||
徙倚
|
||||
太阴
|
||||
若何
|
||||
人神
|
||||
声哀
|
||||
郁烈
|
||||
得衷
|
||||
外朗
|
||||
朝霞
|
||||
佳人
|
||||
愿闻
|
||||
愿诚素
|
||||
阴乍阳
|
||||
黄初
|
||||
湍濑之玄芝
|
||||
屏翳
|
||||
狐疑
|
||||
盛年
|
||||
生尘
|
||||
牵牛
|
||||
远而望
|
||||
右荫桂旗
|
||||
之信
|
||||
古人
|
||||
若神
|
||||
朱唇
|
||||
遗情
|
||||
善睐
|
||||
彼者乎
|
||||
抗琼
|
||||
振荡
|
||||
以要
|
||||
回雪
|
||||
款实
|
||||
眷眷
|
||||
通辞
|
||||
之弃
|
||||
江南
|
||||
若往
|
||||
南湘
|
||||
其淑美
|
||||
长川
|
||||
顾望
|
||||
遨以
|
||||
悼良会
|
||||
华茂春松
|
||||
彷徨
|
||||
之明
|
||||
收风
|
||||
乃是
|
||||
奇服
|
||||
水禽
|
||||
言归东
|
||||
修短
|
||||
丹唇
|
||||
背下陵
|
Loading…
Reference in new issue