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, 有 ...
随机推荐
- 张超超OC基础回顾_05 property修饰符,id类型,instancetype。。。
一.property 如果给一个属性同时提供了getter/setter方法, 那么我们称这个属性为可读可写属性 如果只提供了getter方法, 那么我们称这个属性为只读属性 如果只提供了setter ...
- 虚拟机Ubuntu16.04安装lrzsz
[系统环境] 宿主机:Win7 64位 虚拟机软件:Vmware workstation 12 虚拟机:Ubuntu 16.0.4 [目的] 配合Secure CRT使用rz,sz,方便在Ubuntu ...
- Newtonsoft 序列化和反序列化特殊处理
1>序列化,时间格式化处理 JsonConvert.SerializeObject(Iar, new JsonSerializerSettings() { DateFormatString = ...
- 特征选择Boruta
A good feature subset is one that: contains features highly correlated with (predictive of) the clas ...
- Mybatis_映射文件配置
获取自增主键的值 若数据库支持自动生成主键的字段(比如 MySQL 和 SQL Server),则可以设置 useGeneratedKeys=”true”,然后再把 keyProperty 设置到目标 ...
- Python基础入门-数据类型
一.变量 1)变量定义 在python中,我们可以把变量理解为一个值,变量是一个标签名,变量是有对应的一个值. name = 100(name是变量名 = 号是赋值号100是变量的值) 2)变量赋值 ...
- RPLiDAR 激光雷达探测地面高程
LiDAR,又称激光探测与测量,全程Light Detection And Ranging,这种技术使用激光测量地物(如森林和建筑物)的高程.它的原理十分类似于使用声波来测绘海底地形的声呐技术,或使用 ...
- LIS问题---HDU1025 Constructing Roads In JGShining's Kingdom
发现这个说的比较通俗: 假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7,可以看出来它的LIS长度为5.下面一步一步试着找出它.我们定义一个序列B,然后令 i = 1 to 9 ...
- POJ - 3984 迷宫问题 BFS求具体路径坐标
迷宫问题 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, ...
- MongoDB整理笔记の增加节点
MongoDB Replica Sets 不仅提供高可用性的解决方案,它也同时提供负载均衡的解决方案,增减Replica Sets 节点在实际应用中非常普遍,例如当应用的读压力暴增时,3 台节点的环境 ...