Intelligent Poetry
Readme:
Creat poems.
- import re
- import random
- from collections import Counter
- def Creat_Poem(number):
- w=random.sample(poem,number)
- for i in range(number//4):
- print(w[i],end='')
- print(',',end='')
- for i in range(number//4,number//2):
- print(w[i],end='')
- print('。')
- for i in range(number//2,number//4*3):
- print(w[i],end='')
- print(',',end='')
- for i in range(number//4*3,number):
- print(w[i],end='')
- print('。')
- return
- dic=[]
- data=open('tangshi.txt','r')
- for i in data.readlines():
- dic.append(i.strip().replace(':','').replace(',','').replace('。','').replace('?','').replace('!','').replace('[','').replace(']',''))
- word=''.join(dic)
- word_str=re.sub(r"(?<=\w)","",word)
- word_list= list(word_str)
- a= [i for i in word_list if not str(i).isdigit()]
- s =Counter(a).most_common(300)
- poem=[]
- for i in s:
- poem.append(i[0])
- number=int(input('Merciful Sir,\n\tPlease input the Number of Words:\n\t'))
- print()
- Creat_Poem(number)
Intelligent Poetry
Intelligent Poetry的更多相关文章
- HDU 4287 Intelligent IME(字典树数组版)
Intelligent IME Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 读书笔记-Autonomous Intelligent Vehicles(一)
Autonomous intelligent vehicles have to finish the basic procedures: perceiving and modeling environ ...
- CodeForces Gym 100500A A. Poetry Challenge DFS
Problem A. Poetry Challenge Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- UVa 10361 Automatic Poetry
Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 3 ...
- HDU 4287 Intelligent IME hash
Intelligent IME Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- UVA10361 - Automatic Poetry
“Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!” In Tomb Raider XIV, Lara is, ...
- Bleed Brake Master Cylinder with Intelligent Tester IT2
When the brake fluid level drops too low in the master cylinder reservoir, air bubbles can get caugh ...
- HDU 4287 Intelligent IME
Intelligent IME Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu Intelligent IME
算法:字典树 题意:手机9键拼音:2:abc 3:def 4:ghi 5:jkl 6:mno 7:pqrs 8:tuv 9:wxyz: 第一行读入一个T,代表测试组数: 之后输入两个整数n和m, 有 ...
随机推荐
- 在Build Path中包含其他工程
------------siwuxie095 在 TestBuildPath 的 Build Path 中包含 SupportProje ...
- pt-table-checksum、pt-table-sync核对主从库一致性
一.下载并安装工具http://www.percona.com/downloads/percona-toolkit/目前最新的版本是percona-toolkit_2.2.12.tar.gz上传到服务 ...
- 10个强大的Javascript表单验证插件推荐
创建一个JavaScript表单验证插件,可以说是一个繁琐的过程,涉及到初期设计.开发与测试等等环节.实际上一个优秀的程序员不仅是技术高手,也应该是善假于外物的.本文介绍了10个不错的JavaScri ...
- 数字图像处理实验(14):PROJECT 06-01,Web-Safe Colors 标签: 图像处理MATLAB 2017-05-27 20:45 116人阅读
实验要求: Objective: To know what are Web-safe colors, how to generate the RGB components for a given jp ...
- Luogu 3350 [ZJOI2016]旅行者
BZOJ 4456 听若干个大佬讲过$n$遍终于写掉了. 我把时限基本上跑满了2333…… 分治 + 最短路. 首先我们去分治这个矩形格子,找到一条长边把它对半切,对切开的边上的每一个点跑一遍最短路然 ...
- Monkey进行压力测试定位问题分析
Monkey测试的log分析,我们可以通过几个关键词来判断测试是否通过. 分析log方法一(粗糙一点): 1)Monkey finished打开LOG,查看log的最下端,是否有类似以下字段:## ...
- Monkey测试异常信息解读
查看包名 1.cmd 下面输入 adb locat > D:\test.txt 2.ctrl+c 停掉刚刚 1 运行的进程 3.打开test.txt文件--搜索 Displayed 对应的内 ...
- 编写高质量代码改善C#程序的157个建议——建议32:总是优先考虑泛型
建议32:总是优先考虑泛型 泛型的优点是多方面的,无论泛型类还是泛型方法都同时具备可重用性.类型安全性和高效率等特性,这是非泛型和非泛型方法无法具备的. 以可重用性为例: class MyList { ...
- Android Service基本知识总结(一)
一.简介 Service是Android系统的后台服务组件,适用于开发无界面.长时间运行的应用功能Service特点如下: 没有用户界面 不会轻易被Android系统终止 在系统资源恢复后Servic ...
- asp.net get图
前段 <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=& ...