# -*- coding:utf-8 -*-
#模仿自: http://www.jianshu.com/p/f893291674ca
#python惡俗古風詩自動生成器
from random import sample
import time
import os
words="""朱砂 天下 殺伐 人家 韶華 風華 繁華 血染 墨染 白衣 素衣 嫁衣 傾城 孤城 空城 舊城 舊人 伊人 心疼 春風 古琴 無情 迷離 奈何 斷弦 焚盡 散亂 陌路 亂世 笑靨 淺笑 明眸 輕嘆 煙火 一生 三生 浮生 桃花 梨花 落花 煙花 離殤 情殤 愛殤 劍殤 灼傷 倉皇 匆忙 陌上 清商 焚香 墨香 微涼 斷腸 痴狂 凄涼 黃梁 未央 成雙 無恙 虛妄 凝霜 洛陽 長安 江南 忘川 千年 紙傘 煙雨 回眸 公子 紅塵 紅顏 紅衣 紅豆 紅線 青絲 青史 青冢 白發 白首 白骨 黃土 黃泉 碧落 紫陌情深緣淺 情深不壽 莫失莫忘 陰陽相隔 如花美眷 似水流年 眉目如畫 曲終人散 繁華落盡 不訴離殤 一世長安
"""
temp=["xx,xx,xx了xx。","xxxx,xxxx,不過是一場xxxx。",
"你說xxxx,我說xxxx,最后不過xxxx。","xx,xx,許我一場xxxx。",
"一x一x一xx,半x半x半xx。","你說xxxxxxxx,后來xxxxxxxx。","xxxx,xxxx,終不敵xxxx。"]
word1=words.replace(" ","").replace("\n","")
word2=[r for r in words.split() if len(r)==2]
word4=[r for r in words.split() if len(r)==4]
def bard():
temp1=sample(temp,1)[0]
while "xxxx" in temp1:
temp1=temp1.replace("xxxx",sample(word4,1)[0],1)
while "xx" in temp1:
temp1=temp1.replace("xx",sample(word2,1)[0],1)
while "x" in temp1:
temp1=temp1.replace("x",sample(word1,1)[0],1)
print(temp1)
os.system("@title python版惡俗古風詩生成器")
for r in range(99):
bard()
time.sleep(1)