From c9185fbd0a8631518bf668f5925d149f857848b3 Mon Sep 17 00:00:00 2001 From: david-ajax Date: Mon, 4 Aug 2025 01:24:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compositions.py | 103 +++++++++++----- electron/陈情表.toml | 279 +++++++++++++++++++++++++++++++++++++++++++ main.py | 63 +++++----- nucleon/陈情表.toml | 222 +++++++++++++++++----------------- reactor.py | 4 + styles.tcss | 10 +- 6 files changed, 504 insertions(+), 177 deletions(-) diff --git a/compositions.py b/compositions.py index 009ab5a..ef682f0 100644 --- a/compositions.py +++ b/compositions.py @@ -4,11 +4,11 @@ from textual.widgets import Collapsible, Header, Footer, Markdown, ListView, Lis from textual.containers import Container, Horizontal, Center from textual.screen import Screen from textual.widget import Widget -import pathlib +import uuid from typing import Tuple, Dict import particles as pt -import uuid -from functools import wraps +import puzzles as pz +import re class Composition(): def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]): @@ -24,12 +24,15 @@ class Composition(): if id_ not in self.reg.keys(): return "None" return self.reg[id_] + def recid(self, id_): + return id_[:-36] def compose(self): yield Label("示例标签", id="testlabel") yield Button("示例按钮", id="testbtn") - def handler(self, event): - print(event.button.id) - self.screen.query_one("#testlabel", Label).update("hi") + def handler(self, event, type_): + if hasattr(event, "button"): + #print(event.button.id) + self.screen.query_one("#testlabel", Label).update("hi") class Placeholder(Composition): def __init__(self, screen: Screen): @@ -37,8 +40,8 @@ class Placeholder(Composition): def compose(self): yield Label("示例标签", id="testlabel") yield Button("示例按钮", id="testbtn", classes="choice") - def handler(self, event): - print(event.button.id) + def handler(self, event, type_): + #print(event.button.id) self.screen.query_one("#testlabel", Label).update("hi") class Recognition(Composition): @@ -48,17 +51,32 @@ class Recognition(Composition): with Center(): yield Static(f"[dim]{self.atom[1]['translation']}[/]") yield Label(f"") - with Center(): - yield Label(f"[b][b]{self.atom[1]['content']}[/][/]", id=self.regid("sentence")) # 致敬传奇去重串 uuid + s = str(self.atom[1]['content']) + replace_dict = { + ", ": ",", + ". ": ".", + "; ": ";", + ": ": ":", + "/,": ",", + "./": ".", + "/;": ";", + ";/": ";", + ":/": ":", + } + for old, new in replace_dict.items(): + s = s.replace(old, new) + result = re.split(r"(?<=[,;:|])", s.replace('/', ' ')) + for i in result: + with Center(): + yield Label(f"[b][b]{i.replace("/", " ")}[/][/]", id=self.regid("sentence"+str(hash(i)))) # 致敬传奇去重串 uuid #with Collapsible(title="附加信息", collapsed=True): for i in self.atom[2]["testdata"]["additional_inf"]: if self.atom[1][i]: - print(type(self.atom[1][i])) - print(self.atom[1][i]) + #print(type(self.atom[1][i])) + #print(self.atom[1][i]) if isinstance(self.atom[1][i], list): for j in self.atom[1][i]: - print(999) - yield Markdown(f"### {self.atom[2]["keydata"][i]}: {j}") + yield Markdown(f"### {self.atom[2]['keydata'][i]}: {j}") continue if isinstance(self.atom[1][i], Dict): t = "" @@ -67,33 +85,52 @@ class Recognition(Composition): yield Markdown(t, id=self.regid("tran")) with Center(): yield Button("我已知晓", id=self.regid("ok")) - def handler(self, event): - if event.button.id == self.getid("ok"): - print(1) - """"""#assessment = self.reactor.report(self.reactor.current_atom, -1) - return 0 + def handler(self, event, type_): + ##print(event) + if type_ == "button": + #print(event.button.id) + if event.button.id == self.getid("ok"): + #print(1) + """"""#assessment = self.reactor.report(self.reactor.current_atom, -1) + return 0 + if type_ == 1: + pass + return -1 class BasicEvaluation(Composition): def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]): super().__init__(screen, reactor, atom) def compose(self): yield Label(self.atom[1]["content"], id="sentence") - for i in self.atom[2]["testdata"]["additional_inf"]: - yield Label(f"{self.atom[2]["keydata"][i]}: {self.atom[1][i]}", id=f"label_{i}") - yield Button("我已知晓", id="ok") - def handler(self, event): - if event.button.id == "ok": - return 1 + with Container(id="button_container"): + btn = {} + btn['5'] = Button("完美回想", variant="success", id=self.regid("feedback5"), classes="choice") + btn['4'] = Button("犹豫后正确", variant="success", id=self.regid("feedback4"), classes="choice") + btn['3'] = Button("困难地正确", variant="warning", id=self.regid("feedback3"), classes="choice") + btn['2'] = Button("错误但熟悉", variant="warning", id=self.regid("feedback2"), classes="choice") + btn['1'] = Button("错误且不熟", variant="error", id=self.regid("feedback1"), classes="choice") + btn['0'] = Button("完全空白", variant="error", id=self.regid("feedback0"), classes="choice") + yield Horizontal(btn['5'], btn['4']) + yield Horizontal(btn['3'], btn['2']) + yield Horizontal(btn['1'], btn['0']) + def handler(self, event, type_): + if "feedback" in event.button.id: + #print(self.recid(event.button.id)[8:9]) + assess = int(self.recid(event.button.id)[8:9]) + ret = self.reactor.report(self.atom, assess) + return ret class FillBlank(Composition): - def __init__(self, screen: Screen, atom: Tuple[pt.Electron, pt.Nucleon, Dict]): - """"""#super().__init__(screen, atom) + def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]): + super().__init__(screen, reactor, atom) + def _work(self): + self.puzzle = pz.BlankPuzzle(self.atom[1]["content"], 4) + self.puzzle.refresh() def compose(self): - yield Label(self.atom[1]["content"], id="sentence") - for i in self.atom[2]["testdata"]["additional_inf"]: - yield Label(f"{self.atom[2]["keydata"][i]}: {self.atom[1][i]}", id=f"label_{i}") + self._work() + yield Label(self.puzzle.wording, id="sentence") yield Button("我已知晓", id="ok") - def handler(self, event): + def handler(self, event, type_): if event.button.id == "ok": return 1 @@ -101,7 +138,7 @@ class FillBlank(Composition): registry = { "sample": Composition, "recognition": Recognition, - "fill_blank_test": FillBlank, + "fill_blank_test": BasicEvaluation, "draw_card_test": BasicEvaluation, "basic_evaluation": BasicEvaluation, } @@ -121,7 +158,7 @@ class TestScreen(Screen): pass def on_button_pressed(self, event: Event) -> None: - self.comp.handler(event) + self.comp.handler(event, "button") def action_quit_app(self) -> None: self.app.exit() diff --git a/electron/陈情表.toml b/electron/陈情表.toml index e69de29..a32172d 100644 --- a/electron/陈情表.toml +++ b/electron/陈情表.toml @@ -0,0 +1,279 @@ +["臣/密/言: /臣/以/险衅/, 夙/遭/闵凶./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241563.9242582 + +["生孩/六月/, 慈父/见背/; /行年/四岁/, 舅/夺/母志./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241564.467116 + +["祖母/刘/愍/臣/孤弱/, 躬亲/抚养./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241565.3159063 + +["臣/少/多/疾病/, 九岁/不行/, 零丁/孤苦/, 至于/成立./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241566.100317 + +["既/无/伯叔/, 终/鲜/兄弟/, 门/衰/祚/薄/, 晚/有/儿息./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241566.9799266 + +["外/无/期功/强近/之亲/, 内/无/应门/五尺/之僮/, 茕茕/孑立/, 形影/相吊./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241567.6606886 + +["而/刘/夙/婴/疾病/, 常/在/床蓐/, 臣/侍/汤药/, 未曾/废离./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241568.2600803 + +["逮/奉/圣朝/, 沐浴/清化./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241568.6842272 + +["前/太守/臣/逵/察/臣/孝廉/; /后/刺史/臣/荣/举/臣/秀才./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241569.060461 + +["臣/以/供养/无主/, 辞/不赴命./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241569.4603384 + +["诏书/特下/, 拜/臣/郎中/, 寻/蒙/国恩/, 除/臣/洗马./"] +efactor = 2.5 +real_rept = 2 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241569.8361027 + +["猥/以/微贱/, 当/侍/东宫/, 非/臣/陨首/所能/上报./"] +efactor = 2.5 +real_rept = 6 +rept = 0 +interval = 1 +last_date = 10 +next_date = 11 +is_activated = 1 +last_modify = 1754241571.6039598 + +["臣/具/以表/闻/, 辞/不就职./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075471 + +["诏书/切峻/, 责/臣/逋慢/; /郡县/逼迫/, 催/臣/上道/; /州司/临门/, 急于/星火./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.007548 + +["臣/欲/奉诏/奔驰/, 则/刘/病/日笃/, 欲/苟/顺/私情/, 则/告诉/不许./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075495 + +["臣/之/进退/, 实为/狼狈./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075507 + +["伏惟/圣朝/以/孝/治/天下/, 凡/在/故老/, 犹/蒙/矜育/, 况/臣/孤苦/, 特为/尤甚./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075517 + +["且/臣/少/仕/伪朝/, 历职/郎署/, 本图/宦达/, 不矜/名节./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075529 + +["今/臣/亡国/贱俘/, 至微/至陋/, 过/蒙/拔擢/, 宠命/优渥/, 岂敢/盘桓/, 有所/希冀!/"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075538 + +["但/以/刘/日薄/西山/, 气息/奄奄/, 人命/危浅/, 朝不/虑夕./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075545 + +["臣/无/祖母/, 无以/至今日/, 祖母/无/臣/, 无以/终余年./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075557 + +["母孙/二人/, 更相/为命/, 是以/区区/不能/废远./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.007557 + +["臣/密/今年/四十/有四/, 祖母/今年/九十/有六/, 是/臣/尽节/于/陛下/之日/长/, 报养/刘/之日/短./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.007558 + +["乌鸟/私情/, 愿/乞/终养./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075595 + +["臣/之/辛苦/, 非独/蜀之/人士/及/二州/牧伯/所见/明知/, 皇天/后土/, 实所/共鉴./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075607 + +["愿/陛下/矜悯/愚诚/, 听/臣/微志/, 庶/刘/侥幸/, 保/卒/余年./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.0075655 + +["臣/生/当/陨首/, 死/当/结草./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.007567 + +["臣/不胜/犬马/怖惧/之情/, 谨/拜表/以闻./"] +efactor = 2.5 +real_rept = 0 +rept = 0 +interval = 0 +last_date = 0 +next_date = 0 +is_activated = 0 +last_modify = 1754241555.007568 diff --git a/main.py b/main.py index 3cd1417..96bb87a 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,11 @@ from textual.app import App, ComposeResult -from textual.widgets import Header, Footer, ListView, DirectoryTree, ListItem, Label, Static, Button -from textual.containers import Container, Horizontal +from textual.widgets import Header, Footer, ListView, ProgressBar, DirectoryTree, ListItem, Label, Static, Button +from textual.containers import Container, Horizontal, Center from textual.screen import Screen import pathlib import threading import edge_tts as tts from playsound import playsound -from textual.logging import TextualHandler import particles as pt from reactor import Reactor, Apparatus @@ -46,17 +45,19 @@ class MemScreen(Screen): self.reactor = Reactor(nucleon_file, electron_file, self, tasked_num) self.stage = 1 self.stage += self.reactor.set_round_templated(self.stage) - #print(self.reactor.procession) + ##print(self.reactor.procession) self.reactor.forward() #self.compo:compo.Composition = compo.Placeholder(self) self.compo = next(self.reactor.current_appar) def compose(self) -> ComposeResult: - print(self.compo) + #print(self.compo) yield Header(show_clock=True) - with Container(id="main_container"): - yield from self.compo.compose() + with Center(): + yield Static(f"{len(self.reactor.procession) - self.reactor.index}/{len(self.reactor.procession)}") + #yield ProgressBar(total=len(self.reactor.procession) - 1, show_percentage=False, show_eta=False, id="progress") + yield from self.compo.compose() yield Footer() """ @@ -69,27 +70,23 @@ class MemScreen(Screen): pass def on_button_pressed(self, event): - ret = self.compo.handler(event) - """feedback_label = self.query_one("#feedback", Static) - if type(event) == str: - btnid = event - else: - btnid = event.button.id - btnid = str(btnid) - quality = int(btnid.replace('q', '')) - assessment = self.reactor.report(self.reactor.current_atom, quality) - """ - # 遵循 perror 返回值规则 + ret = self.compo.handler(event, "button") + self._forward_judge(ret) + + def _forward_judge(self, ret): + if ret == -1: + return if ret == 0: # 成功 try: self.compo = next(self.reactor.current_appar) self.refresh_ui() except StopIteration: nxt = self.reactor.forward(1) - print(2) - self.compo = next(self.reactor.current_appar) - print(self.compo) - #print("next", nxt, self.reactor.current_atom) + #print(2) + try: + self.compo = next(self.reactor.current_appar) + except: + pass if nxt == -1: if self.reactor.round_set == 0: if self.stage == 4: @@ -101,6 +98,8 @@ class MemScreen(Screen): self.reactor.forward(1) #self._update_ui() self.stage += 1 + self.compo = next(self.reactor.current_appar) + self.refresh_ui() return return else: @@ -109,14 +108,14 @@ class MemScreen(Screen): if ret == 1: # 不允许前进 self.refresh_ui() return - + def refresh_ui(self): - area = self.query_one("#main_container") self.call_later(self.recompose) - #print(area.children) + #self.call_later(lambda: self.query_one("#progress", expect_type=ProgressBar).advance(self.reactor.index)) + ##print(area.children) #for child in list(area.children): # child.remove() # 致敬传奇组件树 DOM - #print(1,list(self.compo.compose())) + ##print(1,list(self.compo.compose())) #area.mount(*list(self.compo.compose())) def report(self, quality): @@ -143,17 +142,17 @@ class MemScreen(Screen): #feedback_label.update("") # 清除反馈消息 self._update_ui()""" - def action_press(self, btnid): - self.on_button_pressed(btnid) + #def action_press(self, btnid): + # self.on_button_pressed(btnid) def action_play_voice(self): def play(): cache_dir = pathlib.Path(f"./cache/voice/") cache_dir.mkdir(parents = True, exist_ok = True) - cache = cache_dir / f"{self.reactor.current_atom[1].content}.wav" + cache = cache_dir / f"{self.reactor.current_atom[1].content.replace("/","")}.wav" if not cache.exists(): - communicate = tts.Communicate(self.reactor.current_atom[1].content, "zh-CN-YunjianNeural") - communicate.save_sync(f"./cache/voice/{self.reactor.current_atom[1].content}.wav") + communicate = tts.Communicate(self.reactor.current_atom[1].content.replace("/",""), "zh-CN-YunjianNeural") + communicate.save_sync(f"./cache/voice/{self.reactor.current_atom[1].content.replace("/","")}.wav") playsound(str(cache)) threading.Thread(target=play).start() @@ -267,7 +266,7 @@ class AppLauncher(App): } def on_mount(self) -> None: - self.action_toggle_dark() + #self.action_toggle_dark() self.push_screen("file_selection_screen") if __name__ == "__main__": diff --git a/nucleon/陈情表.toml b/nucleon/陈情表.toml index 29bf48d..0be3c5c 100644 --- a/nucleon/陈情表.toml +++ b/nucleon/陈情表.toml @@ -13,142 +13,142 @@ fill_blank_test = ["translation"] # 选择题测试 draw_card_test = ["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 = {"切峻"="急切而严厉", "逋慢"="逃避怠慢", "星火"="流星的光,喻急迫"} +["诏书/切峻/, 责/臣/逋慢/; /郡县/逼迫/, 催/臣/上道/; /州司/临门/, 急于/星火./"] +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 = "臣下我怀着牛马一样不胜恐惧的心情,恭敬地呈上此表来使陛下知道这件事" +["臣/不胜/犬马/怖惧/之情/, 谨/拜表/以闻./"] +note = [] +translation = "臣下我怀着牛马一样不胜恐惧的心情, 恭敬地呈上此表来使陛下知道这件事" keyword_note = {"不胜"="禁不住", "犬马怖惧"="臣子谦卑的自比", "闻"="使...知道"} \ No newline at end of file diff --git a/reactor.py b/reactor.py index f112fd0..daaef53 100644 --- a/reactor.py +++ b/reactor.py @@ -133,6 +133,10 @@ class Reactor(): self.electron_file.save() def report(self, atom, quality): + """ + 0: 初次激活/通过 + 1: 不通过 + """ if atom in self.atoms_new: atom[0].revisor(quality, True) return 0 diff --git a/styles.tcss b/styles.tcss index 56b6784..3423466 100644 --- a/styles.tcss +++ b/styles.tcss @@ -1,5 +1,6 @@ Screen { - align: center middle; + align: center bottom; + } #main_container { @@ -10,6 +11,13 @@ Screen { padding: 2; } +#vice_container { + align: center middle; + width: 95%; + height: auto; + padding: 2; +} + #sentence { content-align: center middle; width: 100%;