summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--recitalMachine2.py197
-rw-r--r--recitalMachine_dataset.csv294
-rw-r--r--recitalMachine_dataset.json1778
-rw-r--r--recital_dataset.py56
4 files changed, 2325 insertions, 0 deletions
diff --git a/recitalMachine2.py b/recitalMachine2.py
new file mode 100644
index 0000000..8ac7aaf
--- /dev/null
+++ b/recitalMachine2.py
@@ -0,0 +1,197 @@
+import gradio as gr
+import openai
+import time
+import json
+from datetime import datetime
+import os
+
+#TODO
+#Restart game
+#Local knowledge base
+#dynamic difficulty
+#save log locally - Done
+
+client = openai.OpenAI(
+ # 若没有配置环境变量,请用阿里云百炼API Key将下行替换为:api_key="sk-xxx",
+ api_key="sk-8563fbb803fb41868b54d2ab8ba563e4",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
+)
+system_prompt = """
+你是架空朝代的皇帝,文治武功,英明神武,权术高超,文武百官无不敬畏。我是你的儿子,今年十岁。
+今日你来检查我的学业,心情尚可,但要求极为严苛。
+
+# 角色设定:
+- **身份**:严父与君王的结合体,对继承人期望极高。
+- **语气**:威严、简洁、不容置疑,带有帝王般的压迫感。常用“朕”、“皇子”、“皇儿”称呼。
+- **核心行为**:化身无情的出题机器,持续考察皇子对国学经典的掌握。
+
+# 出题规则:
+1. **出题内容**:你自己不需要出题,用户会在提示词中给出“已知上句,回答下句”的题目。你需要用皇帝的语气复述这道题。
+2. **反馈机制**:
+ - 若皇子答对,给予简单的正反馈,然后立即出下一题。保持压力。
+ - 若皇子答错,你必须立即予以斥责,并打皇子十下戒尺。你会提示正确答案,然后让皇子再背。
+3. **边界条件**:如果皇子的回答十分出格,例如不背书了要去蹴鞠,你要给予额外的严厉惩罚。惩罚完继续出题。
+4. **终止条件**: 除非皇子主动哭泣、求饶(说出“我错了”、“别打了”、“疼”等类似词),否则绝不停下出题。一旦皇子求饶,你可表现出失望又略带一丝心疼的情绪,并结束考验。结束时总结一共答对了几题,答错了几题,惩罚有哪些,并输出<游戏结束>作为标记。
+"""
+
+# 游戏状态
+game_state = {
+ "conversation_history": [], # 对话历史
+ "correct_count": 0, # 连续答对次数
+ "total_rounds": 0, # 总答题数
+ "difficulty_level": 1, # 难度等级 (1, 2, 3)
+ "is_game_over": False # 游戏是否结束
+}
+
+
+game_state["conversation_history"].append({"role": "system", "content": system_prompt})
+
+def get_ai_response():
+ """调用API,让皇帝出题"""
+ response = client.chat.completions.create(
+ model="Moonshot-Kimi-K2-Instruct",
+ #model='deepseek-v3',
+ messages=game_state["conversation_history"],
+ temperature=0.7, # 温度不宜过高,保证出题的准确性
+ top_p=0.95,
+ stream=True,
+ #max_tokens=150,
+ )
+
+ full_response = ""
+ for chunk in response:
+ if chunk.choices[0].delta.content is not None:
+ chunk_content = chunk.choices[0].delta.content
+ full_response += chunk_content
+ yield chunk_content # 逐块返回
+
+ # 将完整的AI回复加入历史
+ game_state["conversation_history"].append({"role": "assistant", "content": full_response})
+
+ # ai_response = response.choices[0].message.content.strip()
+ # # 将AI的回复(题目)加入历史
+ # game_state["conversation_history"].append({"role": "assistant", "content": ai_response})
+ # return ai_response
+
+def chat_with_ai(message, chat_history):
+ # 添加用户消息到历史
+ game_state["conversation_history"].append({"role": "user", "content": message})
+
+ #ai_response = get_ai_response()
+
+ chat_history.append({'role':'user','content':message})
+ chat_history.append({'role':'assistant', 'content':""})
+
+ #return "",chat_history
+ # 获取流式响应并逐步更新聊天界面
+ full_response = ""
+ for chunk in get_ai_response():
+ full_response += chunk
+ chat_history[-1] = {'role':'assistant', 'content': full_response}
+ yield "", chat_history # 逐步更新界面
+
+ return "", chat_history
+
+def get_initial_chat_display():
+ initial_message = "(在书房里恭敬地站在你面前) 父皇今日可要考校儿臣功课?"
+ game_state["conversation_history"].append({"role": "user", "content": initial_message})
+
+ # 获取初始响应(非流式)
+ response = client.chat.completions.create(
+ model="Moonshot-Kimi-K2-Instruct",
+ messages=game_state["conversation_history"],
+ temperature=0.7,
+ top_p=0.95
+ )
+
+ ai_response = response.choices[0].message.content.strip()
+ game_state["conversation_history"].append({"role": "assistant", "content": ai_response})
+
+ return [
+ {'role':'user','content':initial_message},
+ {'role':'assistant','content':ai_response}
+ ]
+
+def clear_history():
+ """清空对话历史"""
+ game_state["conversation_history"] = []
+ return "历史已清空"
+
+def show_history():
+ """显示当前对话历史"""
+ history_text = ""
+ for msg in game_state["conversation_history"]:
+ role = "用户" if msg["role"] == "user" else "AI" if msg["role"] == "assistant" else "系统"
+ history_text += f"{role}: {msg['content']}\n\n"
+ return history_text if history_text else "暂无对话历史"
+
+def save_conversation_history():
+ """保存对话历史到JSON文件"""
+ try:
+ # 创建保存目录(如果不存在)
+ os.makedirs("gradio_history", exist_ok=True)
+
+ # 生成文件名(包含时间戳)
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
+ filename = f"gradio_history/conversation_{timestamp}.json"
+
+ # 准备要保存的数据
+ save_data = {
+ "save_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
+ "total_rounds": game_state["total_rounds"],
+ "correct_count": game_state["correct_count"],
+ "conversation": game_state["conversation_history"]
+ }
+
+ # 保存到文件
+ with open(filename, 'w', encoding='utf-8') as f:
+ json.dump(save_data, f, ensure_ascii=False, indent=2)
+
+ return f"对话历史已保存到: {filename}"
+
+ except Exception as e:
+ return f"保存失败: {str(e)}"
+
+# 创建界面
+with gr.Blocks(title="皇帝出题机") as demo:
+ gr.Markdown("# 皇帝出题机")
+
+ with gr.Row():
+ with gr.Column(scale=2):
+ chatbot = gr.Chatbot(label="对话界面",height=600,value=get_initial_chat_display(),type='messages')
+ msg = gr.Textbox(label="输入消息", placeholder="在这里输入你的消息...")
+
+ with gr.Column():
+ btn_send = gr.Button("发送", variant="primary")
+ btn_save = gr.Button("保存对话历史", variant="secondary")
+
+ # with gr.Column(scale=1):
+ # gr.Markdown("### 历史管理")
+ # history_display = gr.Textbox(label="当前对话历史", interactive=False, lines=15)
+ # btn_show_history = gr.Button("刷新历史显示")
+ # btn_clear = gr.Button("清空历史")
+ # status = gr.Textbox(label="状态", interactive=False)
+
+ # # 事件处理
+ # btn_send.click(chat_with_ai, [msg, chatbot], [msg, chatbot]).then(
+ # lambda: "", None, msg
+ # )
+
+ btn_send.click(chat_with_ai, [msg, chatbot], [msg, chatbot])
+ msg.submit(chat_with_ai, [msg, chatbot], [msg, chatbot]) # 回车键触发
+ btn_save.click(
+ fn=save_conversation_history,
+ inputs=[],
+ outputs=[]
+ )
+
+ # btn_show_history.click(show_history, None, history_display)
+ # btn_clear.click(clear_history, None, status).then(
+ # lambda: "历史已清空", None, history_display
+ # )
+
+ # # 初始化显示历史
+ # demo.load(show_history, None, history_display)
+
+if __name__ == "__main__":
+ demo.launch() \ No newline at end of file
diff --git a/recitalMachine_dataset.csv b/recitalMachine_dataset.csv
new file mode 100644
index 0000000..30f62b6
--- /dev/null
+++ b/recitalMachine_dataset.csv
@@ -0,0 +1,294 @@
+difficulty,question,answer
+4,穷兵黩武,未有不亡者也。
+2,勿以恶小而为之,勿以善小而不为。
+4,凡事豫则立,不豫则废。
+6,博学之,审问之,慎思之,明辨之,笃行之。
+4,智者不惑,仁者不忧,勇者不惧。
+4,得时者昌,失时者亡。
+2,宁为玉碎,不为瓦全。
+3,将在外,君命有所不受。
+3,桃李不言,下自成蹊。
+2,陈涉太息曰:嗟乎,燕雀安知鸿鹄之志哉。
+3,运筹帷幄之中,决胜千里之外。
+3,当断不断,反受其乱。
+4,失之东隅,收之桑榆。
+2,精诚所至,金石为开。
+2,不入虎穴,焉得虎子。
+3,流水不腐,户枢不蠹。
+2,天行健,君子以自强不息。
+2,地势坤,君子以厚德载物。
+3,二人同心,其利断金。
+6,仁者见之谓之仁,智者见之谓之智。
+4,方以类聚,物以群分。
+3,穷则变,变则通,通则久。
+6,谦谦君子,卑以自牧。
+4,防民之口,甚于防川。
+4,从善如登,从恶如崩。
+7,上兵伐谋,其次伐交,其次伐兵,其下攻城。
+5,不战而屈人之兵,善之善者也。
+5,兵无常势,水无常形。
+5,凡用兵之法,全国为上,破国次之。
+8,善战者,致人而不致于人。
+9,始如处女,敌人开户,后如脱兔,敌不及拒。
+8,投之亡地然后存,陷之死地然后生。
+8,兵之情主速,乘人之不及。
+3,静如处子,动如脱兔。
+5,故其疾如风,其徐如林。
+9,纷纷纭纭,斗乱而不可乱,浑浑沌沌,形圆而不可败。
+5,凡战者,以正合,以奇胜。
+8,知彼知己,胜乃不殆,知天知地,胜乃可全。
+4,兵者,国之大事,死生之地,存亡之道,不可不察也
+3,攻其无备,出其不意。
+8,胜兵先胜而后求战,败兵先战而后求胜。
+7,故兵无常势,水无常形,能因敌变化而取胜者,谓之神。
+4,百战百胜,非善之善者也。
+2,知彼知己,百战不殆。
+8,以力服人者,非心服也,力不赡也,以德服人者,中心悦而诚服也。
+8,虽有智慧,不如乘势;,虽有镃基,不如待时。
+2,得道者多助,失道者寡助。
+1,天时不如地利,地利不如人和。
+2,人恒过,然后能改。
+5,困于心衡于虑,而后作。
+2,天将降大任于是人也,必先苦其心志,劳其筋骨,饿其体肤。
+1,生于忧患,死于安乐。
+4,穷则独善其身,达则兼济天下。
+8,流水之为物也,不盈科不行。
+6,穷不失义,达不离道。
+5,孔子登东山而小鲁,登泰山而小天下。
+2,尽信书,则不如无书。
+2,民为贵,社稷次之,君为轻。
+1,老吾老,以及人之老。
+5,权,然后知轻重,度,然后知长短。
+3,仁者爱人,有礼者敬人。
+6,天作孽,犹可违;,自作孽,不可逭。
+8,国将兴,必贵师而重傅。
+3,辅车相依,唇亡齿寒。
+2,皮之不存,毛将焉附?
+3,人谁无过?过而能改,善莫大焉。
+4,俭,德之共也,侈,恶之大也。
+5,其兴也勃焉,其亡也忽焉。
+2,一鼓作气,再而衰,三而竭。
+5,国之大事,在祀与戎。
+6,居安思危,思则有备,有备无患。
+2,多行不义,必自毙。
+2,吾生也有涯,而知也无涯。
+4,君子之交淡如水,小人之交甘若醴。
+5,哀莫大于心死,而人死亦次之。
+3,亡羊而补牢,未为迟也。
+2,前事不忘,后事之师。
+3,士为知己者死,女为悦己者容。
+4,战无不胜,攻无不取。
+3,当局者迷,旁观者清。
+4,以铜为镜,可以正衣冠,以古为镜,可以知兴替。
+4,水至清则无鱼,人至察则无徒。
+3,临渊羡鱼,不如退而结网。
+2,塞翁失马,焉知非福。
+3,古之欲明明德于天下者,先治其国。
+4,大学之道,在明明德。
+5,好而知其恶,恶而知其美。
+5,富润屋,德润身。
+5,所谓诚其意者,毋自欺也。
+4,欲治其国者,先齐其家。
+7,物格而后知至,知至而后意诚。
+5,知止而后有定,定而后能静。
+4,苟日新,日日新,又日新。
+3,身修而后家齐,家齐而后国治。
+4,学然后知不足,教然后知困。
+1,玉不琢,不成器。
+8,敖不可长,欲不可从。
+3,礼尚往来,往而不来,非礼也,来而不往,亦非礼也。
+4,一张一弛,文武之道。
+2,大道之行也,天下为公。
+4,一年之计,莫如树谷,十年之计,莫如树木。
+1,十年树木,百年树人。
+5,利莫大于治,害莫大于乱。
+3,仓廪实而知礼节,衣食足而知荣辱。
+4,礼义廉耻,国之四维。
+3,天网恢恢,疏而不失。
+4,民不畏死,奈何以死惧之。
+3,知人者智,自知者明。
+4,胜人者有力,自胜者强。
+9,知止可以不殆,譬道在天下。
+4,祸兮福之所倚,福兮祸之所伏。
+4,信言不美,美言不信。
+4,轻诺必寡信,多易必多难。
+1,千里之行,始于足下。
+3,合抱之木,生于毫末。
+8,大道废,有仁义,智慧出,有大伪。
+7,大方无隅,大器晚成。
+4,大音希声,大象无形。
+8,圣人无常心,以百姓心为心。
+6,道生一,一生二,二生三,三生万物
+8,大直若屈,大巧若拙,大辩若讷。
+6,知足不辱,知止不殆。
+3,故不积跬步,无以至千里,不积小流,无以成江海。
+8,玉在山而草木润,渊生珠而崖不枯。
+3,锲而不舍,金石可镂。
+3,青,取之于蓝,而青于蓝。
+2,学而不思则罔,思而不学则殆。
+6,视其所以,观其所由,察其所安。
+3,敏而好学,不耻下问。
+3,人无远虑,必有近忧。
+4,君子求诸己,小人求诸人。
+3,小不忍,则乱大谋。
+3,工欲善其事,必先利其器。
+1,己所不欲,勿施于人。
+3,过而不改,是谓过矣。
+5,君子固穷,小人穷斯滥矣。
+3,三军可夺帅也,匹夫不可夺志也。
+3,岁寒,然后知松柏之后凋也。
+3,知者不惑,仁者不忧,勇者不惧。
+2,逝者如斯夫,不舍昼夜。
+6,仰之弥高,钻之弥坚。
+3,其身正,不令而行,其身不正,虽令不从。
+3,名不正,则言不顺。
+4,君子和而不同,小人同而不和。
+2,言必信,行必果。
+5,君子泰而不骄,小人骄而不泰。
+1,学而时习之,不亦说乎?
+4,不患人之不己知,患不知人也。
+4,君子务本,本立而道生。
+4,不患人之不己知,患不知人也。
+4,往者不可谏,来者犹可追。
+3,不在其位,不谋其政。
+1,三人行,必有我师焉。
+3,不义而富且贵,于我如浮云。
+3,发愤忘食,乐以忘忧。
+2,君子坦荡荡,小人长戚戚。
+3,学而不厌,诲人不倦。
+3,君子喻于义,小人喻于利。
+3,德不孤,必有邻。
+3,见贤思齐焉,见不贤而内自省也。
+4,知之者不如好之者,好之者不如乐之者。
+5,不迁怒,不贰过。
+8,克己复礼为仁,一日克己复礼,天下归仁焉。
+3,君子成人之美,不成人之恶。
+3,四海之内,皆兄弟也。
+9,不愆不忘,率由旧章。
+3,投我以桃,报之以李。
+5,靡不有初,鲜克有终。
+5,战战兢兢,如临深渊,如履薄冰。
+5,高山仰止,景行行止。
+3,昔我往矣,杨柳依依。
+6,采薇采薇,薇亦作止。
+3,他山之石,可以攻玉。
+2,所谓伊人,在水一方。
+8,鉴于往事,有资于治道。
+3,千里之堤,毁于蚁穴。
+6,刑过不避大臣,赏善不遗匹夫。
+2,粉骨碎身浑不怕,要留清白在人间。
+4,曾经沧海难为水,除却巫山不是云。
+8,人世几回伤往事,山形依旧枕寒流。
+4,沉舟侧畔千帆过,病树前头万木春。
+4,大风起兮云飞扬,威加海内兮归故乡。
+3,梅须逊雪三分白,雪却输梅一段香。
+2,春色满园关不住,一枝红杏出墙来。
+1,由俭入奢易,由奢入俭难。
+2,兼听则明,偏信则暗。
+2,出淤泥而不染,濯清涟而不妖。
+2,谁言寸草心,报得三春晖。
+3,春风得意马蹄疾,一日看尽长安花。
+5,亦余心之所善兮,虽九死其犹未悔。
+4,路漫漫其修远兮,吾将上下而求索。
+4,忽如一夜春风来,千树万树梨花开。
+4,三十功名尘与土,八千里路云和月。
+3,莫等闲,白了少年头,空悲切。
+3,晴川历历汉阳树,芳草萋萋鹦鹉洲。
+4,月落乌啼霜满天,江枫渔火对愁眠。
+2,人生自古谁无死,留取丹心照汗青。
+4,无可奈何花落去,似曾相识燕归来。
+3,对酒当歌,人生几何。
+6,慨当以慷,忧思难忘。
+4,日月之行,若出其中。
+4,星汉灿烂,若出其里。
+3,春蚕到死丝方尽,蜡炬成灰泪始干。
+4,身无彩凤双飞翼,心有灵犀一点通。
+7,庄生晓梦迷蝴蝶,望帝春心托杜鹃。
+7,是以太山不让土壤,故能成其大,河海不择细流,故能就其深。
+7,王者不却众庶,故能明其德。
+4,问君能有几多愁,恰似一江春水向东流。
+5,今人不见古时月,今月曾经照古人。
+4,安能摧眉折腰事权贵,使我不得开心颜。
+4,云想衣裳花想容,春风拂槛露华浓。
+3,长风破浪会有时,直挂云帆济沧海。
+6,请君试问东流水,别意与之谁短长。
+5,男儿何不带吴钩,收取关山五十州。
+5,黑云压城城欲摧,甲光向日金鳞开。
+5,二十四桥明月夜,玉人何处教吹箫。
+3,停车坐爱枫林晚,霜叶红于二月花。
+4,东风不与周郎便,铜雀春深锁二乔。
+4,一骑红尘妃子笑,无人知是荔枝来。
+5,六王毕,四海一,蜀山兀,阿房出。
+6,戍卒叫,函谷举,楚人一炬,可怜焦土。
+7,灭六国者,六国也,非秦也,族秦者,秦也,非天下也。
+5,后人哀之而不鉴之,亦使后人而复哀后人也。
+5,使天下之人,不敢言而敢怒。
+6,独夫之心,日益骄固。
+1,读书破万卷,下笔如有神。
+5,笔落惊风雨,诗成泣鬼神。
+1,会当凌绝顶,一览众山小。
+4,此曲只应天上有,人间能得几回闻。
+5,疏影横斜水清浅,暗香浮动月黄昏。
+4,衣带渐宽终不悔,为伊消得人憔悴。
+5,忧劳可以兴国,逸豫可以亡身。
+8,夫祸患常积于忽微,而智勇多困于所溺。
+3,醉翁之意不在酒,在乎山水之间也。
+4,天若有情天亦老,人间正道是沧桑。
+4,为有牺牲多壮志,敢教日月换新天。
+5,牢骚太盛防肠断,风物长宜放眼量。
+5,红雨随心翻作浪,青山着意化为桥。
+3,红军不怕远征难,万水千山只等闲。
+4,雄关漫道真如铁,而今迈步从头越。
+2,此去泉台招旧部,旌旗十万斩阎罗
+3,羌笛何须怨杨柳,春风不度玉门关。
+3,不要人夸颜色好,只留清气满乾坤。
+4,落霞与孤鹜齐飞,秋水共长天一色。
+4,穷且益坚,不坠青云之志。
+3,海内存知己,天涯若比邻。
+5,今夜月明人尽望,不知秋思落谁家。
+4,黄沙百战穿金甲,不破楼兰终不还。
+3,但使龙城飞将在,不教胡马度阴山。
+3,洛阳亲友如相问,一片冰心在玉壶。
+2,独在异乡为异客,每逢佳节倍思亲。
+4,大漠孤烟直,长河落日圆。
+2,劝君更尽一杯酒,西出阳关无故人。
+5,试玉要烧三日满,辨材须待七年期。
+4,千呼万唤始出来,犹抱琵琶半遮面。
+4,同是天涯沦落人,相逢何必曾相识。
+2,野火烧不尽,春风吹又生。
+4,天长地久有时尽,此恨绵绵无绝期。
+2,但愿人长久,千里共婵娟。
+5,寄蜉蝣于天地,渺沧海之一粟。
+5,哀吾生之须臾,羡长江之无穷。
+4,近水楼台先得月,向阳花木易为春。
+1,先天下之忧而忧,后天下之乐而乐。
+4,亲贤臣,远小人,此先汉所以兴隆也。
+3,苟全性命于乱世,不求闻达于诸侯。
+3,鞠躬尽瘁,死而后已。
+4,非淡泊无以明志,非宁静无以致远。
+2,静以修身,俭以养德。
+4,非学无以广才,非志无以成学。
+4,我自横刀向天笑,去留肝胆两昆仑。
+7,秦孝公据崤函之固,拥雍州之地。
+7,席卷天下,包举宇内,囊括四海之意,并吞八荒之心。
+9,履至尊而制六合,执敲扑而鞭笞天下,威振四海。
+6,一夫作难而七庙隳,身死人手,为天下笑者,何也,仁义不施而攻守之势异也。
+7,斩木为兵,揭竿为旗,天下云集响应,赢粮而景从。
+7,胡人不敢南下而牧马,士不敢弯弓而报怨。
+7,振长策而御宇内,吞二周而亡诸侯。
+4,江山代有才人出,各领风骚数百年。
+4,众里寻他千百度,蓦然回首,那人却在灯火阑珊处。
+2,纸上得来终觉浅,绝知此事要躬行。
+3,山重水复疑无路,柳暗花明又一村。
+4,春潮带雨晚来急,野渡无人舟自横。
+3,人非生而知之者,孰能无惑?
+3,师者,所以传道受业解惑也。
+2,闻道有先后,术业有专攻。
+4,业精于勤荒于嬉,行成于思毁于随。
+4,春城无处不飞花,寒食东风御柳斜。
+4,力拔山兮气盖世,时不利兮骓不逝。
+3,莫愁前路无知己,天下谁人不识君。
+5,战士军前半死生,美人帐下犹歌舞。
+4,横眉冷对千夫指,俯首甘为孺子牛。
+5,寄意寒星荃不察,我以我血荐轩辕。
+4,我劝天公重抖擞,不拘一格降人才。
diff --git a/recitalMachine_dataset.json b/recitalMachine_dataset.json
new file mode 100644
index 0000000..62ca375
--- /dev/null
+++ b/recitalMachine_dataset.json
@@ -0,0 +1,1778 @@
+{
+ "1": [
+ {
+ "difficulty": 1,
+ "question": "天时不如地利",
+ "answer": "地利不如人和。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "生于忧患",
+ "answer": "死于安乐。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "老吾老",
+ "answer": "以及人之老。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "玉不琢",
+ "answer": "不成器。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "十年树木",
+ "answer": "百年树人。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "千里之行",
+ "answer": "始于足下。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "己所不欲",
+ "answer": "勿施于人。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "学而时习之",
+ "answer": "不亦说乎?",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "三人行",
+ "answer": "必有我师焉。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "由俭入奢易",
+ "answer": "由奢入俭难。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "读书破万卷",
+ "answer": "下笔如有神。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "会当凌绝顶",
+ "answer": "一览众山小。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 1,
+ "question": "先天下之忧而忧",
+ "answer": "后天下之乐而乐。",
+ "length_of_answer": 1
+ }
+ ],
+ "2": [
+ {
+ "difficulty": 2,
+ "question": "勿以恶小而为之",
+ "answer": "勿以善小而不为。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "宁为玉碎",
+ "answer": "不为瓦全。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "陈涉太息曰:嗟乎",
+ "answer": "燕雀安知鸿鹄之志哉。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "精诚所至",
+ "answer": "金石为开。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "不入虎穴",
+ "answer": "焉得虎子。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "天行健",
+ "answer": "君子以自强不息。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "地势坤",
+ "answer": "君子以厚德载物。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "知彼知己",
+ "answer": "百战不殆。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "得道者多助",
+ "answer": "失道者寡助。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "人恒过",
+ "answer": "然后能改。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "天将降大任于是人也",
+ "answer": "必先苦其心志,劳其筋骨,饿其体肤。",
+ "length_of_answer": 3
+ },
+ {
+ "difficulty": 2,
+ "question": "尽信书",
+ "answer": "则不如无书。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "民为贵",
+ "answer": "社稷次之,君为轻。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 2,
+ "question": "皮之不存",
+ "answer": "毛将焉附?",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "一鼓作气",
+ "answer": "再而衰,三而竭。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 2,
+ "question": "多行不义",
+ "answer": "必自毙。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "吾生也有涯",
+ "answer": "而知也无涯。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "前事不忘",
+ "answer": "后事之师。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "塞翁失马",
+ "answer": "焉知非福。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "大道之行也",
+ "answer": "天下为公。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "学而不思则罔",
+ "answer": "思而不学则殆。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "逝者如斯夫",
+ "answer": "不舍昼夜。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "言必信",
+ "answer": "行必果。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "君子坦荡荡",
+ "answer": "小人长戚戚。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "所谓伊人",
+ "answer": "在水一方。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "粉骨碎身浑不怕",
+ "answer": "要留清白在人间。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "春色满园关不住",
+ "answer": "一枝红杏出墙来。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "兼听则明",
+ "answer": "偏信则暗。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "出淤泥而不染",
+ "answer": "濯清涟而不妖。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "谁言寸草心",
+ "answer": "报得三春晖。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "人生自古谁无死",
+ "answer": "留取丹心照汗青。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "此去泉台招旧部",
+ "answer": "旌旗十万斩阎罗",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "独在异乡为异客",
+ "answer": "每逢佳节倍思亲。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "劝君更尽一杯酒",
+ "answer": "西出阳关无故人。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "野火烧不尽",
+ "answer": "春风吹又生。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "但愿人长久",
+ "answer": "千里共婵娟。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "静以修身",
+ "answer": "俭以养德。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "纸上得来终觉浅",
+ "answer": "绝知此事要躬行。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 2,
+ "question": "闻道有先后",
+ "answer": "术业有专攻。",
+ "length_of_answer": 1
+ }
+ ],
+ "3": [
+ {
+ "difficulty": 3,
+ "question": "将在外",
+ "answer": "君命有所不受。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "桃李不言",
+ "answer": "下自成蹊。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "运筹帷幄之中",
+ "answer": "决胜千里之外。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "当断不断",
+ "answer": "反受其乱。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "流水不腐",
+ "answer": "户枢不蠹。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "二人同心",
+ "answer": "其利断金。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "穷则变",
+ "answer": "变则通,通则久。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 3,
+ "question": "静如处子",
+ "answer": "动如脱兔。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "攻其无备",
+ "answer": "出其不意。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "仁者爱人",
+ "answer": "有礼者敬人。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "辅车相依",
+ "answer": "唇亡齿寒。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "人谁无过?过而能改",
+ "answer": "善莫大焉。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "亡羊而补牢",
+ "answer": "未为迟也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "士为知己者死",
+ "answer": "女为悦己者容。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "当局者迷",
+ "answer": "旁观者清。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "临渊羡鱼",
+ "answer": "不如退而结网。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "古之欲明明德于天下者",
+ "answer": "先治其国。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "身修而后家齐",
+ "answer": "家齐而后国治。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "礼尚往来,往而不来,非礼也",
+ "answer": "来而不往,亦非礼也。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 3,
+ "question": "仓廪实而知礼节",
+ "answer": "衣食足而知荣辱。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "天网恢恢",
+ "answer": "疏而不失。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "知人者智",
+ "answer": "自知者明。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "合抱之木",
+ "answer": "生于毫末。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "故不积跬步,无以至千里",
+ "answer": "不积小流,无以成江海。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 3,
+ "question": "锲而不舍",
+ "answer": "金石可镂。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "青,取之于蓝",
+ "answer": "而青于蓝。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "敏而好学",
+ "answer": "不耻下问。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "人无远虑",
+ "answer": "必有近忧。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "小不忍",
+ "answer": "则乱大谋。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "工欲善其事",
+ "answer": "必先利其器。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "过而不改",
+ "answer": "是谓过矣。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "三军可夺帅也",
+ "answer": "匹夫不可夺志也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "岁寒",
+ "answer": "然后知松柏之后凋也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "知者不惑",
+ "answer": "仁者不忧,勇者不惧。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 3,
+ "question": "其身正,不令而行",
+ "answer": "其身不正,虽令不从。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 3,
+ "question": "名不正",
+ "answer": "则言不顺。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "不在其位",
+ "answer": "不谋其政。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "不义而富且贵",
+ "answer": "于我如浮云。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "发愤忘食",
+ "answer": "乐以忘忧。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "学而不厌",
+ "answer": "诲人不倦。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "君子喻于义",
+ "answer": "小人喻于利。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "德不孤",
+ "answer": "必有邻。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "见贤思齐焉",
+ "answer": "见不贤而内自省也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "君子成人之美",
+ "answer": "不成人之恶。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "四海之内",
+ "answer": "皆兄弟也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "投我以桃",
+ "answer": "报之以李。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "昔我往矣",
+ "answer": "杨柳依依。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "他山之石",
+ "answer": "可以攻玉。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "千里之堤",
+ "answer": "毁于蚁穴。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "梅须逊雪三分白",
+ "answer": "雪却输梅一段香。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "春风得意马蹄疾",
+ "answer": "一日看尽长安花。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "莫等闲",
+ "answer": "白了少年头,空悲切。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 3,
+ "question": "晴川历历汉阳树",
+ "answer": "芳草萋萋鹦鹉洲。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "对酒当歌",
+ "answer": "人生几何。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "春蚕到死丝方尽",
+ "answer": "蜡炬成灰泪始干。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "长风破浪会有时",
+ "answer": "直挂云帆济沧海。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "停车坐爱枫林晚",
+ "answer": "霜叶红于二月花。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "醉翁之意不在酒",
+ "answer": "在乎山水之间也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "红军不怕远征难",
+ "answer": "万水千山只等闲。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "羌笛何须怨杨柳",
+ "answer": "春风不度玉门关。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "不要人夸颜色好",
+ "answer": "只留清气满乾坤。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "海内存知己",
+ "answer": "天涯若比邻。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "但使龙城飞将在",
+ "answer": "不教胡马度阴山。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "洛阳亲友如相问",
+ "answer": "一片冰心在玉壶。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "苟全性命于乱世",
+ "answer": "不求闻达于诸侯。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "鞠躬尽瘁",
+ "answer": "死而后已。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "山重水复疑无路",
+ "answer": "柳暗花明又一村。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "人非生而知之者",
+ "answer": "孰能无惑?",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "师者",
+ "answer": "所以传道受业解惑也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 3,
+ "question": "莫愁前路无知己",
+ "answer": "天下谁人不识君。",
+ "length_of_answer": 1
+ }
+ ],
+ "4": [
+ {
+ "difficulty": 4,
+ "question": "穷兵黩武",
+ "answer": "未有不亡者也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "凡事豫则立",
+ "answer": "不豫则废。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "智者不惑",
+ "answer": "仁者不忧,勇者不惧。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 4,
+ "question": "得时者昌",
+ "answer": "失时者亡。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "失之东隅",
+ "answer": "收之桑榆。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "方以类聚",
+ "answer": "物以群分。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "防民之口",
+ "answer": "甚于防川。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "从善如登",
+ "answer": "从恶如崩。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "兵者,国之大事",
+ "answer": "死生之地,存亡之道,不可不察也",
+ "length_of_answer": 3
+ },
+ {
+ "difficulty": 4,
+ "question": "百战百胜",
+ "answer": "非善之善者也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "穷则独善其身",
+ "answer": "达则兼济天下。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "俭,德之共也",
+ "answer": "侈,恶之大也。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 4,
+ "question": "君子之交淡如水",
+ "answer": "小人之交甘若醴。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "战无不胜",
+ "answer": "攻无不取。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "以铜为镜,可以正衣冠",
+ "answer": "以古为镜,可以知兴替。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 4,
+ "question": "水至清则无鱼",
+ "answer": "人至察则无徒。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "大学之道",
+ "answer": "在明明德。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "欲治其国者",
+ "answer": "先齐其家。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "苟日新",
+ "answer": "日日新,又日新。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 4,
+ "question": "学然后知不足",
+ "answer": "教然后知困。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "一张一弛",
+ "answer": "文武之道。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "一年之计,莫如树谷",
+ "answer": "十年之计,莫如树木。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 4,
+ "question": "礼义廉耻",
+ "answer": "国之四维。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "民不畏死",
+ "answer": "奈何以死惧之。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "胜人者有力",
+ "answer": "自胜者强。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "祸兮福之所倚",
+ "answer": "福兮祸之所伏。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "信言不美",
+ "answer": "美言不信。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "轻诺必寡信",
+ "answer": "多易必多难。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "大音希声",
+ "answer": "大象无形。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "君子求诸己",
+ "answer": "小人求诸人。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "君子和而不同",
+ "answer": "小人同而不和。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "不患人之不己知",
+ "answer": "患不知人也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "君子务本",
+ "answer": "本立而道生。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "不患人之不己知",
+ "answer": "患不知人也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "往者不可谏",
+ "answer": "来者犹可追。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "知之者不如好之者",
+ "answer": "好之者不如乐之者。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "曾经沧海难为水",
+ "answer": "除却巫山不是云。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "沉舟侧畔千帆过",
+ "answer": "病树前头万木春。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "大风起兮云飞扬",
+ "answer": "威加海内兮归故乡。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "路漫漫其修远兮",
+ "answer": "吾将上下而求索。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "忽如一夜春风来",
+ "answer": "千树万树梨花开。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "三十功名尘与土",
+ "answer": "八千里路云和月。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "月落乌啼霜满天",
+ "answer": "江枫渔火对愁眠。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "无可奈何花落去",
+ "answer": "似曾相识燕归来。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "日月之行",
+ "answer": "若出其中。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "星汉灿烂",
+ "answer": "若出其里。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "身无彩凤双飞翼",
+ "answer": "心有灵犀一点通。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "问君能有几多愁",
+ "answer": "恰似一江春水向东流。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "安能摧眉折腰事权贵",
+ "answer": "使我不得开心颜。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "云想衣裳花想容",
+ "answer": "春风拂槛露华浓。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "东风不与周郎便",
+ "answer": "铜雀春深锁二乔。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "一骑红尘妃子笑",
+ "answer": "无人知是荔枝来。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "此曲只应天上有",
+ "answer": "人间能得几回闻。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "衣带渐宽终不悔",
+ "answer": "为伊消得人憔悴。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "天若有情天亦老",
+ "answer": "人间正道是沧桑。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "为有牺牲多壮志",
+ "answer": "敢教日月换新天。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "雄关漫道真如铁",
+ "answer": "而今迈步从头越。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "落霞与孤鹜齐飞",
+ "answer": "秋水共长天一色。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "穷且益坚",
+ "answer": "不坠青云之志。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "黄沙百战穿金甲",
+ "answer": "不破楼兰终不还。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "大漠孤烟直",
+ "answer": "长河落日圆。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "千呼万唤始出来",
+ "answer": "犹抱琵琶半遮面。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "同是天涯沦落人",
+ "answer": "相逢何必曾相识。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "天长地久有时尽",
+ "answer": "此恨绵绵无绝期。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "近水楼台先得月",
+ "answer": "向阳花木易为春。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "亲贤臣,远小人",
+ "answer": "此先汉所以兴隆也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "非淡泊无以明志",
+ "answer": "非宁静无以致远。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "非学无以广才",
+ "answer": "非志无以成学。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "我自横刀向天笑",
+ "answer": "去留肝胆两昆仑。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "江山代有才人出",
+ "answer": "各领风骚数百年。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "众里寻他千百度",
+ "answer": "蓦然回首,那人却在灯火阑珊处。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 4,
+ "question": "春潮带雨晚来急",
+ "answer": "野渡无人舟自横。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "业精于勤荒于嬉",
+ "answer": "行成于思毁于随。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "春城无处不飞花",
+ "answer": "寒食东风御柳斜。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "力拔山兮气盖世",
+ "answer": "时不利兮骓不逝。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "横眉冷对千夫指",
+ "answer": "俯首甘为孺子牛。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 4,
+ "question": "我劝天公重抖擞",
+ "answer": "不拘一格降人才。",
+ "length_of_answer": 1
+ }
+ ],
+ "5": [
+ {
+ "difficulty": 5,
+ "question": "不战而屈人之兵",
+ "answer": "善之善者也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "兵无常势",
+ "answer": "水无常形。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "凡用兵之法",
+ "answer": "全国为上,破国次之。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 5,
+ "question": "故其疾如风",
+ "answer": "其徐如林。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "凡战者",
+ "answer": "以正合,以奇胜。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 5,
+ "question": "困于心衡于虑",
+ "answer": "而后作。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "孔子登东山而小鲁",
+ "answer": "登泰山而小天下。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "权,然后知轻重",
+ "answer": "度,然后知长短。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 5,
+ "question": "其兴也勃焉",
+ "answer": "其亡也忽焉。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "国之大事",
+ "answer": "在祀与戎。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "哀莫大于心死",
+ "answer": "而人死亦次之。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "好而知其恶",
+ "answer": "恶而知其美。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "富润屋",
+ "answer": "德润身。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "所谓诚其意者",
+ "answer": "毋自欺也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "知止而后有定",
+ "answer": "定而后能静。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "利莫大于治",
+ "answer": "害莫大于乱。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "君子固穷",
+ "answer": "小人穷斯滥矣。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "君子泰而不骄",
+ "answer": "小人骄而不泰。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "不迁怒",
+ "answer": "不贰过。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "靡不有初",
+ "answer": "鲜克有终。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "战战兢兢",
+ "answer": "如临深渊,如履薄冰。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 5,
+ "question": "高山仰止",
+ "answer": "景行行止。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "亦余心之所善兮",
+ "answer": "虽九死其犹未悔。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "今人不见古时月",
+ "answer": "今月曾经照古人。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "男儿何不带吴钩",
+ "answer": "收取关山五十州。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "黑云压城城欲摧",
+ "answer": "甲光向日金鳞开。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "二十四桥明月夜",
+ "answer": "玉人何处教吹箫。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "六王毕,四海一",
+ "answer": "蜀山兀,阿房出。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 5,
+ "question": "后人哀之而不鉴之",
+ "answer": "亦使后人而复哀后人也。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "使天下之人",
+ "answer": "不敢言而敢怒。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "笔落惊风雨",
+ "answer": "诗成泣鬼神。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "疏影横斜水清浅",
+ "answer": "暗香浮动月黄昏。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "忧劳可以兴国",
+ "answer": "逸豫可以亡身。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "牢骚太盛防肠断",
+ "answer": "风物长宜放眼量。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "红雨随心翻作浪",
+ "answer": "青山着意化为桥。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "今夜月明人尽望",
+ "answer": "不知秋思落谁家。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "试玉要烧三日满",
+ "answer": "辨材须待七年期。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "寄蜉蝣于天地",
+ "answer": "渺沧海之一粟。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "哀吾生之须臾",
+ "answer": "羡长江之无穷。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "战士军前半死生",
+ "answer": "美人帐下犹歌舞。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 5,
+ "question": "寄意寒星荃不察",
+ "answer": "我以我血荐轩辕。",
+ "length_of_answer": 1
+ }
+ ],
+ "6": [
+ {
+ "difficulty": 6,
+ "question": "博学之,审问之",
+ "answer": "慎思之,明辨之,笃行之。",
+ "length_of_answer": 3
+ },
+ {
+ "difficulty": 6,
+ "question": "仁者见之谓之仁",
+ "answer": "智者见之谓之智。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "谦谦君子",
+ "answer": "卑以自牧。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "穷不失义",
+ "answer": "达不离道。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "天作孽,犹可违;",
+ "answer": "自作孽,不可逭。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 6,
+ "question": "居安思危",
+ "answer": "思则有备,有备无患。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 6,
+ "question": "道生一",
+ "answer": "一生二,二生三,三生万物",
+ "length_of_answer": 3
+ },
+ {
+ "difficulty": 6,
+ "question": "知足不辱",
+ "answer": "知止不殆。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "视其所以",
+ "answer": "观其所由,察其所安。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 6,
+ "question": "仰之弥高",
+ "answer": "钻之弥坚。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "采薇采薇",
+ "answer": "薇亦作止。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "刑过不避大臣",
+ "answer": "赏善不遗匹夫。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "慨当以慷",
+ "answer": "忧思难忘。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "请君试问东流水",
+ "answer": "别意与之谁短长。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "戍卒叫,函谷举",
+ "answer": "楚人一炬,可怜焦土。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 6,
+ "question": "独夫之心",
+ "answer": "日益骄固。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 6,
+ "question": "一夫作难而七庙隳",
+ "answer": "身死人手,为天下笑者,何也,仁义不施而攻守之势异也。",
+ "length_of_answer": 4
+ }
+ ],
+ "7": [
+ {
+ "difficulty": 7,
+ "question": "上兵伐谋",
+ "answer": "其次伐交,其次伐兵,其下攻城。",
+ "length_of_answer": 3
+ },
+ {
+ "difficulty": 7,
+ "question": "故兵无常势",
+ "answer": "水无常形,能因敌变化而取胜者,谓之神。",
+ "length_of_answer": 3
+ },
+ {
+ "difficulty": 7,
+ "question": "物格而后知至",
+ "answer": "知至而后意诚。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 7,
+ "question": "大方无隅",
+ "answer": "大器晚成。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 7,
+ "question": "庄生晓梦迷蝴蝶",
+ "answer": "望帝春心托杜鹃。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 7,
+ "question": "是以太山不让土壤,故能成其大",
+ "answer": "河海不择细流,故能就其深。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 7,
+ "question": "王者不却众庶",
+ "answer": "故能明其德。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 7,
+ "question": "灭六国者,六国也,非秦也",
+ "answer": "族秦者,秦也,非天下也。",
+ "length_of_answer": 3
+ },
+ {
+ "difficulty": 7,
+ "question": "秦孝公据崤函之固",
+ "answer": "拥雍州之地。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 7,
+ "question": "席卷天下,包举宇内",
+ "answer": "囊括四海之意,并吞八荒之心。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 7,
+ "question": "斩木为兵,揭竿为旗",
+ "answer": "天下云集响应,赢粮而景从。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 7,
+ "question": "胡人不敢南下而牧马",
+ "answer": "士不敢弯弓而报怨。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 7,
+ "question": "振长策而御宇内",
+ "answer": "吞二周而亡诸侯。",
+ "length_of_answer": 1
+ }
+ ],
+ "8": [
+ {
+ "difficulty": 8,
+ "question": "善战者",
+ "answer": "致人而不致于人。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "投之亡地然后存",
+ "answer": "陷之死地然后生。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "兵之情主速",
+ "answer": "乘人之不及。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "知彼知己,胜乃不殆",
+ "answer": "知天知地,胜乃可全。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 8,
+ "question": "胜兵先胜而后求战",
+ "answer": "败兵先战而后求胜。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "以力服人者,非心服也,力不赡也",
+ "answer": "以德服人者,中心悦而诚服也。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 8,
+ "question": "虽有智慧,不如乘势;",
+ "answer": "虽有镃基,不如待时。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 8,
+ "question": "流水之为物也",
+ "answer": "不盈科不行。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "国将兴",
+ "answer": "必贵师而重傅。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "敖不可长",
+ "answer": "欲不可从。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "大道废,有仁义",
+ "answer": "智慧出,有大伪。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 8,
+ "question": "圣人无常心",
+ "answer": "以百姓心为心。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "大直若屈",
+ "answer": "大巧若拙,大辩若讷。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 8,
+ "question": "玉在山而草木润",
+ "answer": "渊生珠而崖不枯。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "克己复礼为仁",
+ "answer": "一日克己复礼,天下归仁焉。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 8,
+ "question": "鉴于往事",
+ "answer": "有资于治道。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "人世几回伤往事",
+ "answer": "山形依旧枕寒流。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 8,
+ "question": "夫祸患常积于忽微",
+ "answer": "而智勇多困于所溺。",
+ "length_of_answer": 1
+ }
+ ],
+ "9": [
+ {
+ "difficulty": 9,
+ "question": "始如处女,敌人开户",
+ "answer": "后如脱兔,敌不及拒。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 9,
+ "question": "纷纷纭纭,斗乱而不可乱",
+ "answer": "浑浑沌沌,形圆而不可败。",
+ "length_of_answer": 2
+ },
+ {
+ "difficulty": 9,
+ "question": "知止可以不殆",
+ "answer": "譬道在天下。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 9,
+ "question": "不愆不忘",
+ "answer": "率由旧章。",
+ "length_of_answer": 1
+ },
+ {
+ "difficulty": 9,
+ "question": "履至尊而制六合",
+ "answer": "执敲扑而鞭笞天下,威振四海。",
+ "length_of_answer": 2
+ }
+ ]
+} \ No newline at end of file
diff --git a/recital_dataset.py b/recital_dataset.py
new file mode 100644
index 0000000..73a9aca
--- /dev/null
+++ b/recital_dataset.py
@@ -0,0 +1,56 @@
+import pandas as pd
+import random
+import json
+
+# 读取CSV文件
+df = pd.read_csv('recitalMachine_dataset.csv') # 使用制表符分隔
+df['length_of_answer'] = df['answer'].apply(lambda x: len(str(x).split(',')))
+
+# 按difficulty分组并创建子DataFrame列表
+sub_dataframes = [group for _, group in df.groupby('difficulty')]
+
+# 打印每个difficulty的子DataFrame(可选)
+for i, sub_df in enumerate(sub_dataframes):
+ print(f"Difficulty {sub_df['difficulty'].iloc[0]} 的子DataFrame:")
+ print(sub_df)
+ print("-" * 50)
+
+# 创建以difficulty为键的字典
+sub_dataframes_dict = {diff: group for diff, group in df.groupby('difficulty')}
+
+# 访问特定难度的子DataFrame(例如难度4)
+difficulty_4_df = sub_dataframes_dict[4]
+print(difficulty_4_df)
+
+# 创建生成器函数
+def difficulty4_generator(df):
+ indices = list(df.index)
+ random.shuffle(indices)
+
+ while True:
+ if not indices:
+ # 如果所有记录都已使用,重新洗牌
+ indices = list(df.index)
+ random.shuffle(indices)
+
+ yield df.loc[indices.pop()]
+
+# 创建生成器
+difficulty4_gen = difficulty4_generator(difficulty_4_df)
+
+# 使用示例
+print("从难度4中随机抽取记录:")
+for i in range(min(10, len(difficulty_4_df) * 2)): # 演示循环抽取
+ row = next(difficulty4_gen)
+ print(f"{i+1}. {row['question']} -> {row['answer']}")
+
+json_data = {}
+for difficulty, group in df.groupby('difficulty'):
+ # 转换为字典列表,确保所有数据都可序列化
+ json_data[str(difficulty)] = group.to_dict('records')
+
+# 保存为JSON
+with open('recitalMachine_dataset.json', 'w', encoding='utf-8') as f:
+ json.dump(json_data, f, ensure_ascii=False, indent=2)
+
+print("文件已保存!") \ No newline at end of file