commit 02e92be9912750ef56613fa13e4bd1066734eaec Author: david-ajax Date: Sat Jul 19 22:33:05 2025 +0800 Next init diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4088ad7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/.DS_Store": true, + "**/Thumbs.db": true + }, + "hide-files.files": [] +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e69de29 diff --git a/nucleon/陈情表.toml b/nucleon/陈情表.toml new file mode 100644 index 0000000..1f55a29 --- /dev/null +++ b/nucleon/陈情表.toml @@ -0,0 +1,139 @@ +["臣密言:臣以险衅, 夙遭闵凶."] +note = [] +translation = "臣子李密陈言:我因命运不好,小时候遭遇到了不幸" +keyword_note = {"险衅":"凶险祸患(这里指命运不好)", "夙":"早时,这里指年幼的时候", "闵":"通'悯',指可忧患的事", "凶":"不幸,指丧父"} + +["生孩六月, 慈父见背;行年四岁, 舅夺母志."] +note = [] +translation = "刚出生六个月,我慈爱的父亲就不幸去世了。经过了四年,舅父逼母亲改嫁" +keyword_note = {"见背":"死的委婉说法", "行年":"经历的年岁", "母志":"母亲守节之志(改嫁的委婉说法)"} + +["祖母刘愍臣孤弱, 躬亲抚养."] +note = [] +translation = "我的祖母刘氏,怜悯我从小丧父,便亲自对我加以抚养" +keyword_note = {"愍":"怜悯", "躬亲":"亲身"} + +["臣少多疾病, 九岁不行, 零丁孤苦, 至于成立."] +note = [] +translation = "臣小的时候经常生病,九岁时还不会行走。孤独无靠,一直到成人自立" +keyword_note = {"成立":"成人自立"} + +["既无伯叔, 终鲜兄弟, 门衰祚薄, 晚有儿息."] +note = [] +translation = "既没有叔叔伯伯,又没什么兄弟,门庭衰微而福分浅薄,很晚才有儿子" +keyword_note = {"鲜":"少,这里指'无'", "祚薄":"福分浅薄", "儿息":"亲生子女"} + +["外无期功强近之亲, 内无应门五尺之僮, 茕茕孑立, 形影相吊."] +note = [] +translation = "在外面没有比较亲近的亲戚,在家里又没有照应门户的童仆。生活孤单没有依靠,每天只有自己的身体和影子相互安慰" +keyword_note = {"期功":"指关系较近的亲属", "茕茕孑立":"孤单无依靠的样子", "吊":"安慰"} + +["而刘夙婴疾病, 常在床蓐, 臣侍汤药, 未曾废离."] +note = [] +translation = "但祖母又早被疾病缠绕,常年卧床不起,我侍奉她吃饭喝药,从来就没有停止侍奉而离开她" +keyword_note = {"婴":"被...缠绕", "蓐":"通'褥',床垫", "废":"停止服侍", "离":"离开"} + +["逮奉圣朝, 沐浴清化."] +note = [] +translation = "到了晋朝建立,我蒙受着清明的政治教化" +keyword_note = {"逮":"及,到", "奉":"承奉", "圣朝":"指当时的晋朝", "沐浴清化":"蒙受清平教化"} + +["前太守臣逵察臣孝廉;后刺史臣荣举臣秀才."] +note = [] +translation = "前任太守逵,考察后推举臣下为孝廉,后任刺史荣又推举臣下为优秀人才" +keyword_note = {"察":"考察和推举", "孝廉":"孝顺,品性纯洁", "举":"推举", "秀才":"优秀人才"} + +["臣以供养无主, 辞不赴命."] +note = [] +translation = "臣下因为供奉赡养祖母的事无人承担,辞谢不接受任命" +keyword_note = {"无主":"无人承担"} + +["诏书特下, 拜臣郎中, 寻蒙国恩, 除臣洗马."] +note = [] +translation = "朝廷又特地下了诏书,任命我为郎中,不久又蒙受国家恩命,任命我为太子洗马" +keyword_note = {"拜":"授予官职", "郎中":"尚书省的属官", "寻":"不久", "除":"拜官受职", "洗马":"太子的属官"} + +["猥以微贱, 当侍东宫, 非臣陨首所能上报."] +note = [] +translation = "像我这样出身微贱地位卑下的人,担当侍奉太子的职务,这实在不是我杀身捐躯所能报答朝廷的" +keyword_note = {"猥":"谦词", "微贱":"卑微低贱", "东宫":"太子居处", "陨首":"杀身"} + +["臣具以表闻, 辞不就职."] +note = [] +translation = "我将以上苦衷上表报告,加以推辞不去就职" +keyword_note = {"具":"详细", "闻":"使...知道"} + +["诏书切峻, 责臣逋慢;郡县逼迫, 催臣上道;州司临门, 急于星火."] +note = [] +translation = "但是诏书急切严峻,责备我逃避命令,有意拖延,态度傲慢。郡县长官催促我立刻上路;州官登门督促,比流星坠落还要急迫" +keyword_note = {"切峻":"急切而严厉", "逋慢":"逃避怠慢", "星火":"流星的光,喻急迫"} + +["臣欲奉诏奔驰, 则刘病日笃, 欲苟顺私情, 则告诉不许."] +note = [] +translation = "我很想遵从皇上的旨意赴京就职,但祖母刘氏的病却一天比一天重;想要姑且顺从自己的私情,但报告申诉不被允许" +keyword_note = {"日笃":"病情日益加重", "苟":"姑且", "告诉":"报告申诉"} + +["臣之进退, 实为狼狈."] +note = [] +translation = "我是进退两难,十分狼狈" +keyword_note = {"狼狈":"进退两难的样子"} + +["伏惟圣朝以孝治天下, 凡在故老, 犹蒙矜育, 况臣孤苦, 特为尤甚."] +note = [] +translation = "我俯伏思量晋朝是用孝道来治理天下的,凡是年老而德高的旧臣,尚且还受到怜悯养育,何况我的孤苦程度更为严重呢" +keyword_note = {"伏惟":"下对上的敬辞", "故老":"年老德高的旧臣", "矜育":"怜悯养育"} + +["且臣少仕伪朝, 历职郎署, 本图宦达, 不矜名节."] +note = [] +translation = "况且我年轻的时候曾经做过蜀汉的官,担任过郎官职务,本来就希望做官显达,并不顾惜名声节操" +keyword_note = {"伪朝":"对前朝的蔑称", "历职":"连续任职", "郎署":"尚书郎的官衙", "宦达":"官场上显达"} + +["今臣亡国贱俘, 至微至陋, 过蒙拔擢, 宠命优渥, 岂敢盘桓, 有所希冀!"] +note = [] +translation = "现在我是一个低贱的亡国俘虏,十分卑微浅陋,受到过分提拔,恩宠优厚,怎敢犹豫不决而有非分的企求呢" +keyword_note = {"拔擢":"提拔", "优渥":"优厚", "盘桓":"徘徊不前", "希冀":"非分的企求"} + +["但以刘日薄西山, 气息奄奄, 人命危浅, 朝不虑夕."] +note = [] +translation = "只是因为祖母刘氏寿命即将终了,气息微弱,生命垂危,早上不能想到晚上怎样" +keyword_note = {"日薄西山":"太阳接近西山,喻人寿命将终", "危浅":"生命垂危"} + +["臣无祖母, 无以至今日, 祖母无臣, 无以终余年."] +note = [] +translation = "臣下我如果没有祖母,就没有今天的样子;祖母如果没有我的照料,也无法度过她的余生" +keyword_note = {"终余年":"度过余生"} + +["母孙二人, 更相为命, 是以区区不能废远."] +note = [] +translation = "我们祖孙二人,互相依靠而维持生命,因此我的内心不愿废止奉养,远离祖母" +keyword_note = {"更相":"相互", "区区":"自己的私情", "废远":"废止奉养而远离"} + +["臣密今年四十有四, 祖母今年九十有六, 是臣尽节于陛下之日长, 报养刘之日短."] +note = [] +translation = "臣下我现在的年龄四十四岁了,祖母现在的年龄九十六岁了,臣下我在陛下面前尽忠尽节的日子还长着呢,而在祖母刘氏面前尽孝尽心的日子已经不多了" +keyword_note = {"有":"又", "尽节":"尽忠节"} + +["乌鸟私情, 愿乞终养."] +note = [] +translation = "我怀着乌鸦反哺的私情,乞求能够准许我完成对祖母养老送终的心愿" +keyword_note = {"乌鸟私情":"乌鸦反哺之情,喻孝心", "终养":"养老至终"} + +["臣之辛苦, 非独蜀之人士及二州牧伯所见明知, 皇天后土, 实所共鉴."] +note = [] +translation = "我的辛酸苦楚,并不仅仅被蜀地的百姓及益州、梁州的长官所亲眼目睹、内心明白,连天地神明也都看得清清楚楚" +keyword_note = {"辛苦":"辛酸苦楚", "牧伯":"州郡长官", "皇天后土":"天地神明", "鉴":"明察"} + +["愿陛下矜悯愚诚, 听臣微志, 庶刘侥幸, 保卒余年."] +note = [] +translation = "希望陛下能怜悯我愚昧诚心,请允许我完成臣下一点小小的心愿,使祖母刘氏能够侥幸地保全她的余生" +keyword_note = {"矜悯":"怜悯", "听":"准许", "庶":"或许(表希望)", "卒余年":"终老"} + +["臣生当陨首, 死当结草."] +note = [] +translation = "我活着应当杀身报效朝廷,死了也要结草衔环来报答陛下的恩情" +keyword_note = {"陨首":"掉脑袋,指献出生命", "结草":"死后报恩的典故"} + +["臣不胜犬马怖惧之情, 谨拜表以闻."] +note = [] +translation = "臣下我怀着牛马一样不胜恐惧的心情,恭敬地呈上此表来使陛下知道这件事" +keyword_note = {"不胜":"禁不住", "犬马怖惧":"臣子谦卑的自比", "闻":"使...知道"} \ No newline at end of file diff --git a/particles.py b/particles.py new file mode 100644 index 0000000..c478d44 --- /dev/null +++ b/particles.py @@ -0,0 +1,83 @@ +import pathlib +import toml +import time +import copy +import datetime +import json + +class Atom(): + """原子: 由电子(分析数据)和核子(材料元数据)组成的反应(运行时)中间对象""" + +class Electron(): + """电子: 记忆分析数据及算法""" + algorithm = "SM-2" + """ + origin = "陈情表" # 来源 + content = "" # 内容 + efactor = 2.5 # 易度系数, 越大越简单, 最大为5 + real_rept = 0 # (实际)重复次数 + rept = 0 # (有效)重复次数 + interval = 0 # 最佳间隔 +ept', last_date = 0 # 上一次复习的时间戳 + next_date = 0 # 将要复习的时间戳 + is_activated = 0 # 激活状态 + # *NOTE: 这里的"时间戳" 是以天为单位的整数, 即 UNIX 时间戳除以一天的秒数取整 + last_modify = 0 # 最后修改时间戳(此处是UNIX时间戳) + """ + def __init__(self, content: str, data: dict): + self.content = content + self.efactor = data.get('efactor', 2.5) + self.real_rept = data.get('real_rept', 0) + self.rept = data.get('rept', 0) + self.interval = data.get('interval', 0) + self.last_date = data.get('last_date', 0) + self.next_date = data.get('next_date', 0) + self.is_activated = data.get('is_activated', 0) + self.last_modify = time.time() + + def activate(self): + self.is_activated = 1 + + def modify(self, var: str, value): + setattr(self, var, value) + self.last_modify = time.time() + + def __hash__(self): + return hash(self.content) + + + @staticmethod + def import_from_file(path: pathlib.Path): + name = path.name.replace(path.suffix, "") + with open(path, 'r') as f: + all = toml.load(f) + lst = list() + for i in all.keys(): + lst.append(Electron(i, all[i])) + return (name, lst) + @staticmethod + def save_to_file(electron_list, path: pathlib.Path): + with open(path, 'w') as f: + toml.dump(electron_list, f) + +class Nucleon(): + """核子: 材料元数据""" + def __init__(self, content: str, data: dict): + self.metadata = data + self.content = content + + @staticmethod + def import_from_file(path: pathlib.Path): + name = path.name.replace(path.suffix, "") + with open(path, 'r') as f: + all = toml.load(f) + lst = list() + for i in all.keys(): + lst.append(Nucleon(i, all[i])) + return (name, lst) + + @staticmethod + def save_to_file(nucleon_list, path: pathlib.Path): + with open(path, 'w') as f: + toml.dump(nucleon_list, f) + \ No newline at end of file diff --git a/reactor.py b/reactor.py new file mode 100644 index 0000000..e69de29