Compare commits
18 Commits
v0.2.9
...
d5ef5e84d0
Author | SHA1 | Date | |
---|---|---|---|
d5ef5e84d0 | |||
dd74dddf00 | |||
2cf2cdb33f | |||
385a86eb2c | |||
46d992b408 | |||
b77f3f2abe | |||
6c28bd461b | |||
44f75bca90 | |||
961f0ba785 | |||
c9185fbd0a | |||
4beb42f615 | |||
445e15646b | |||
4d6d1f1b60 | |||
722ae6f72c | |||
88650b0856 | |||
620473863a | |||
9d8cb17cc6 | |||
123f7919b0 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@
|
|||||||
.directory
|
.directory
|
||||||
__pycache__/
|
__pycache__/
|
||||||
scripts/
|
scripts/
|
||||||
.idea
|
.idea
|
||||||
|
cache
|
41
auxiliary.py
41
auxiliary.py
@@ -1,33 +1,46 @@
|
|||||||
import time
|
import time
|
||||||
import pathlib
|
import pathlib
|
||||||
import toml
|
import toml
|
||||||
|
import typing
|
||||||
|
|
||||||
class ConfigFile():
|
class ConfigFile:
|
||||||
def __init__(self, path):
|
def __init__(self, path: str):
|
||||||
self.path = pathlib.Path(path)
|
self.path = pathlib.Path(path)
|
||||||
if self.path.exists() == 0:
|
if not self.path.exists():
|
||||||
self.path.touch()
|
self.path.touch()
|
||||||
self.data = dict()
|
self.data = dict()
|
||||||
|
self._load()
|
||||||
|
|
||||||
|
def _load(self):
|
||||||
|
"""从文件加载配置数据"""
|
||||||
with open(self.path, 'r') as f:
|
with open(self.path, 'r') as f:
|
||||||
self.data = toml.load(f)
|
try:
|
||||||
def modify(self, key, value):
|
self.data = toml.load(f)
|
||||||
|
except toml.TomlDecodeError:
|
||||||
|
self.data = {}
|
||||||
|
|
||||||
|
def modify(self, key: str, value: typing.Any):
|
||||||
|
"""修改配置值并保存"""
|
||||||
self.data[key] = value
|
self.data[key] = value
|
||||||
self.save()
|
self.save()
|
||||||
def save(self, path=""):
|
|
||||||
if path == "":
|
def save(self, path: typing.Union[str, pathlib.Path] = ""):
|
||||||
path = self.path
|
"""保存配置到文件"""
|
||||||
with open(path, 'w') as f:
|
save_path = pathlib.Path(path) if path else self.path
|
||||||
|
with open(save_path, 'w') as f:
|
||||||
toml.dump(self.data, f)
|
toml.dump(self.data, f)
|
||||||
def get(self, key, default = None):
|
|
||||||
|
def get(self, key: str, default: typing.Any = None) -> typing.Any:
|
||||||
|
"""获取配置值,如果不存在返回默认值"""
|
||||||
return self.data.get(key, default)
|
return self.data.get(key, default)
|
||||||
|
|
||||||
|
|
||||||
def get_daystamp() -> int:
|
def get_daystamp() -> int:
|
||||||
|
"""获取当前日戳(以天为单位的整数时间戳)"""
|
||||||
config = ConfigFile("config.toml")
|
config = ConfigFile("config.toml")
|
||||||
|
|
||||||
time_override = config.get("time_override", -1)
|
time_override = config.get("time_override", -1)
|
||||||
|
|
||||||
if time_override is not None and time_override != -1:
|
if time_override != -1:
|
||||||
#print(f"TIME OVERRIDEED TO {time_override}")
|
|
||||||
return int(time_override)
|
return int(time_override)
|
||||||
|
|
||||||
return int(time.time() // (24 * 3600))
|
return int(time.time() // (24 * 3600))
|
293
compositions.py
Normal file
293
compositions.py
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
from textual.app import App, ComposeResult
|
||||||
|
from textual.events import Event
|
||||||
|
from textual.widgets import (
|
||||||
|
Collapsible,
|
||||||
|
Header,
|
||||||
|
Footer,
|
||||||
|
Markdown,
|
||||||
|
ListView,
|
||||||
|
ListItem,
|
||||||
|
Label,
|
||||||
|
Static,
|
||||||
|
Button,
|
||||||
|
)
|
||||||
|
from textual.containers import Container, Horizontal, Center
|
||||||
|
from textual.screen import Screen
|
||||||
|
from textual.widget import Widget
|
||||||
|
import uuid
|
||||||
|
from typing import Tuple, Dict
|
||||||
|
import particles as pt
|
||||||
|
import puzzles as pz
|
||||||
|
import re
|
||||||
|
import random
|
||||||
|
import copy
|
||||||
|
|
||||||
|
|
||||||
|
class Composition:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
screen: Screen,
|
||||||
|
reactor,
|
||||||
|
atom: Tuple[pt.Electron, pt.Nucleon, Dict] = pt.Atom.placeholder(),
|
||||||
|
):
|
||||||
|
self.screen = screen
|
||||||
|
self.atom = atom
|
||||||
|
from reactor import Reactor
|
||||||
|
|
||||||
|
self.reactor: Reactor = reactor
|
||||||
|
self.reg = dict()
|
||||||
|
|
||||||
|
def regid(self, id_):
|
||||||
|
self.reg[id_] = id_ + str(uuid.uuid4())
|
||||||
|
return self.reg[id_]
|
||||||
|
|
||||||
|
def getid(self, id_):
|
||||||
|
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, type_):
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
class Finished(Composition):
|
||||||
|
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||||
|
super().__init__(screen, reactor, atom)
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
yield Label("本次记忆进程结束", id=self.regid("msg"))
|
||||||
|
|
||||||
|
|
||||||
|
class Placeholder(Composition):
|
||||||
|
def __init__(self, screen: Screen):
|
||||||
|
self.screen = screen
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
yield Label("示例标签", id="testlabel")
|
||||||
|
yield Button("示例按钮", id="testbtn", classes="choice")
|
||||||
|
|
||||||
|
def handler(self, event, type_):
|
||||||
|
self.screen.query_one("#testlabel", Label).update("hi")
|
||||||
|
|
||||||
|
|
||||||
|
class Recognition(Composition):
|
||||||
|
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||||
|
super().__init__(screen, reactor, atom)
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
with Center():
|
||||||
|
yield Static(f"[dim]{self.atom[1]['translation']}[/]")
|
||||||
|
yield Label(f"")
|
||||||
|
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))),
|
||||||
|
)
|
||||||
|
for i in self.atom[2]["testdata"]["additional_inf"]:
|
||||||
|
if self.atom[1][i]:
|
||||||
|
if isinstance(self.atom[1][i], list):
|
||||||
|
for j in self.atom[1][i]:
|
||||||
|
yield Markdown(f"### {self.atom[2]['keydata'][i]}: {j}")
|
||||||
|
continue
|
||||||
|
if isinstance(self.atom[1][i], Dict):
|
||||||
|
t = ""
|
||||||
|
for j, k in self.atom[1][i].items(): # type: ignore
|
||||||
|
# 弱智的 Pylance 类型推导
|
||||||
|
t += f"> **{j}**: {k} \n"
|
||||||
|
yield Markdown(t, id=self.regid("tran"))
|
||||||
|
with Center():
|
||||||
|
yield Button("我已知晓", id=self.regid("ok"))
|
||||||
|
|
||||||
|
def handler(self, event, type_):
|
||||||
|
if type_ == "button":
|
||||||
|
if event.button.id == self.getid("ok"):
|
||||||
|
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")
|
||||||
|
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:
|
||||||
|
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, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||||
|
super().__init__(screen, reactor, atom)
|
||||||
|
self.inputlist = []
|
||||||
|
self.hashtable = {}
|
||||||
|
self._work()
|
||||||
|
|
||||||
|
def _work(self):
|
||||||
|
self.puzzle = pz.BlankPuzzle(self.atom[1]["content"], 4)
|
||||||
|
self.puzzle.refresh()
|
||||||
|
self.ans = copy.copy(self.puzzle.answer)
|
||||||
|
random.shuffle(self.ans)
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
yield Label(self.puzzle.wording, id=self.regid("sentence"))
|
||||||
|
yield Label(f"当前输入: {self.inputlist}", id=self.regid("inputpreview"))
|
||||||
|
for i in self.ans:
|
||||||
|
self.hashtable[str(hash(i))] = i
|
||||||
|
yield Button(i, id=self.regid(f"select{hash(i)}"))
|
||||||
|
yield Button("退格", id=self.regid(f"delete"))
|
||||||
|
|
||||||
|
def handler(self, event, type_):
|
||||||
|
if type_ == "button":
|
||||||
|
if self.recid(event.button.id) == "delete":
|
||||||
|
if len(self.inputlist) > 0:
|
||||||
|
self.inputlist.pop()
|
||||||
|
else:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
self.inputlist.append(self.hashtable[self.recid(event.button.id)[6:]])
|
||||||
|
if len(self.inputlist) < len(self.puzzle.answer):
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
if self.inputlist == self.puzzle.answer:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
self.inputlist = []
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
class DrawCard(Composition):
|
||||||
|
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||||
|
super().__init__(screen, reactor, atom)
|
||||||
|
self.inputlist = []
|
||||||
|
self.hashtable = {}
|
||||||
|
self._work()
|
||||||
|
|
||||||
|
def _work(self):
|
||||||
|
self.puzzle = pz.SelectionPuzzle(self.atom[1]["keyword_note"], [], 2, "选择正确词义: ") # type: ignore
|
||||||
|
self.puzzle.refresh()
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
yield Label(self.atom[1].content.replace("/",""), id=self.regid("sentence"))
|
||||||
|
yield Label(self.puzzle.wording[len(self.inputlist)], id=self.regid("puzzle"))
|
||||||
|
yield Label(f"当前输入: {self.inputlist}", id=self.regid("inputpreview"))
|
||||||
|
for i in self.puzzle.options[len(self.inputlist)]:
|
||||||
|
self.hashtable[str(hash(i))] = i
|
||||||
|
yield Button(i, id=self.regid(f"select{hash(i)}"))
|
||||||
|
yield Button("退格", id=self.regid(f"delete"))
|
||||||
|
|
||||||
|
def handler(self, event, type_):
|
||||||
|
if type_ == "button":
|
||||||
|
if self.recid(event.button.id) == "delete":
|
||||||
|
if len(self.inputlist) > 0:
|
||||||
|
self.inputlist.pop()
|
||||||
|
else:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
self.inputlist.append(self.hashtable[self.recid(event.button.id)[6:]])
|
||||||
|
if len(self.inputlist) < len(self.puzzle.answer):
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
if self.inputlist == self.puzzle.answer:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
self.inputlist = []
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
registry = {
|
||||||
|
"sample": Composition,
|
||||||
|
"recognition": Recognition,
|
||||||
|
"fill_blank_test": FillBlank,
|
||||||
|
"draw_card_test": DrawCard,
|
||||||
|
"basic_evaluation": BasicEvaluation,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TestScreen(Screen):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(name=None, id=None, classes=None)
|
||||||
|
self.comp = Recognition(self, None, pt.Atom.advanced_placeholder())
|
||||||
|
|
||||||
|
def compose(self) -> ComposeResult:
|
||||||
|
yield Header(show_clock=True)
|
||||||
|
yield from self.comp.compose()
|
||||||
|
yield Footer()
|
||||||
|
|
||||||
|
def on_mount(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_button_pressed(self, event: Event) -> None:
|
||||||
|
self.comp.handler(event, "button")
|
||||||
|
|
||||||
|
def action_quit_app(self) -> None:
|
||||||
|
self.app.exit()
|
||||||
|
|
||||||
|
|
||||||
|
class AppLauncher(App):
|
||||||
|
CSS_PATH = "styles.tcss"
|
||||||
|
TITLE = "测试布局"
|
||||||
|
BINDINGS = [("escape", "quit", "退出"), ("d", "toggle_dark", "改变色调")]
|
||||||
|
SCREENS = {
|
||||||
|
"testscreen": TestScreen,
|
||||||
|
}
|
||||||
|
|
||||||
|
def on_mount(self) -> None:
|
||||||
|
self.action_toggle_dark()
|
||||||
|
self.push_screen("testscreen")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = AppLauncher()
|
||||||
|
app.run()
|
@@ -1,8 +1,8 @@
|
|||||||
# [调试] 将更改保存到文件
|
# [调试] 将更改保存到文件
|
||||||
save = 1
|
save = 1
|
||||||
# [调试] 覆写时间
|
# [调试] 覆写时间
|
||||||
time_override = 11
|
time_override = 10
|
||||||
# 对于每个项目的新记忆核子数量
|
# 对于每个项目的新记忆核子数量
|
||||||
tasked_number = 12
|
tasked_number = 8
|
||||||
# 竖屏适配
|
# 竖屏适配
|
||||||
mobile_mode = 1
|
mobile_mode = 1
|
40
install.bat
Normal file
40
install.bat
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
@echo off
|
||||||
|
echo "HeurAMS 环境安装脚本"
|
||||||
|
echo "正在检测系统中是否安装 Python 3.x..."
|
||||||
|
|
||||||
|
rem 检查 Python 3 是否存在
|
||||||
|
where python >nul 2>nul
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo "错误: 未检测到 Python. 请确保 Python 已添加到系统 PATH 中,然后再次运行此脚本。"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
rem 检查 Python 版本是否为 3.x
|
||||||
|
for /f "tokens=*" %%i in ('python -c "import sys; print(f'{sys.version_info.major}')"') do set PYTHON_MAJOR_VERSION=%%i
|
||||||
|
if "%PYTHON_MAJOR_VERSION%"=="3" (
|
||||||
|
for /f "tokens=*" %%i in ('python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"') do set PYTHON_VERSION=%%i
|
||||||
|
echo "检测到 Python 3 已安装, 版本为: %PYTHON_VERSION%"
|
||||||
|
) else (
|
||||||
|
echo "错误: 未检测到 Python 3. 请先安装 Python 3, 然后再次运行此脚本."
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "---"
|
||||||
|
echo "正在安装 requirements.txt 中的依赖..."
|
||||||
|
|
||||||
|
rem 检查 requirements.txt 文件是否存在
|
||||||
|
if exist "requirements.txt" (
|
||||||
|
python -m pip install -r requirements.txt
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo "依赖安装成功."
|
||||||
|
) else (
|
||||||
|
echo "错误: 依赖安装失败. 请检查 requirements.txt 文件或网络连接."
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
echo "警告: 未找到 requirements.txt 文件. 跳过依赖安装."
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "---"
|
||||||
|
echo "HeurAMS 的环境依赖已安装"
|
||||||
|
pause
|
28
install.sh
Normal file
28
install.sh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "HeurAMS 环境安装脚本"
|
||||||
|
echo "正在检测系统中是否安装 Python 3.x..."
|
||||||
|
if command -v python3 &>/dev/null; then
|
||||||
|
PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
||||||
|
echo "检测到 Python 3 已安装, 版本为: ${PYTHON_VERSION}"
|
||||||
|
else
|
||||||
|
echo "错误: 未检测到 Python 3. 请先安装 Python 3, 然后再次运行此脚本. "
|
||||||
|
exit 1 # 退出脚本, 因为 Python 3 是必需的
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "---"
|
||||||
|
echo "正在安装 requirements.txt 中的依赖..."
|
||||||
|
if [ -f "requirements.txt" ]; then
|
||||||
|
python3 -m pip install -r requirements.txt
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "依赖安装成功. "
|
||||||
|
else
|
||||||
|
echo "错误: 依赖安装失败. 请检查 requirements.txt 文件或网络连接. "
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "警告: 未找到 requirements.txt 文件. 跳过依赖安装. "
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "---"
|
||||||
|
echo "HeurAMS 的环境依赖已安装"
|
245
main.py
245
main.py
@@ -1,21 +1,43 @@
|
|||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.widgets import Header, Footer, ListView, ListItem, Label, Static, Button
|
from textual.widgets import (
|
||||||
from textual.containers import Container, Horizontal
|
Header,
|
||||||
|
Footer,
|
||||||
|
ListView,
|
||||||
|
ProgressBar,
|
||||||
|
DirectoryTree,
|
||||||
|
ListItem,
|
||||||
|
Label,
|
||||||
|
Static,
|
||||||
|
Button,
|
||||||
|
)
|
||||||
|
from textual.containers import Container, Horizontal, Center
|
||||||
from textual.screen import Screen
|
from textual.screen import Screen
|
||||||
import pathlib
|
import pathlib
|
||||||
import threading
|
import threading
|
||||||
import edge_tts as tts
|
import edge_tts as tts
|
||||||
from playsound import playsound
|
from playsound import playsound
|
||||||
from textual.logging import TextualHandler
|
|
||||||
|
|
||||||
import particles as pt
|
import particles as pt
|
||||||
from reactor import Reactor
|
from reactor import Reactor, Apparatus
|
||||||
import auxiliary as aux
|
import auxiliary as aux
|
||||||
|
import compositions as compo
|
||||||
|
import builtins
|
||||||
|
|
||||||
ver = '0.2.9'
|
_original_open = builtins.open
|
||||||
|
|
||||||
|
|
||||||
|
def _open(*args, **kwargs):
|
||||||
|
if "encoding" not in kwargs:
|
||||||
|
kwargs["encoding"] = "utf-8"
|
||||||
|
return _original_open(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
builtins.open = _open
|
||||||
|
|
||||||
|
ver = "0.3.0b"
|
||||||
|
|
||||||
config = aux.ConfigFile("config.toml")
|
config = aux.ConfigFile("config.toml")
|
||||||
|
|
||||||
|
|
||||||
class MemScreen(Screen):
|
class MemScreen(Screen):
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
("d", "toggle_dark", "改变色调"),
|
("d", "toggle_dark", "改变色调"),
|
||||||
@@ -35,119 +57,110 @@ class MemScreen(Screen):
|
|||||||
("/", "press('q0')", None),
|
("/", "press('q0')", None),
|
||||||
]
|
]
|
||||||
btn = dict()
|
btn = dict()
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
nucleon_file: pt.NucleonUnion,
|
nucleon_file: pt.NucleonUnion,
|
||||||
electron_file: pt.ElectronUnion,
|
electron_file: pt.ElectronUnion,
|
||||||
tasked_num
|
tasked_num,
|
||||||
):
|
):
|
||||||
super().__init__(name=None, id=None, classes=None)
|
super().__init__(name=None, id=None, classes=None)
|
||||||
self.reactor = Reactor(nucleon_file, electron_file, tasked_num)
|
self.reactor = Reactor(nucleon_file, electron_file, self, tasked_num)
|
||||||
self.stage = 1
|
self.stage = 1
|
||||||
self.stage += self.reactor.set_round_templated(self.stage)
|
self.stage += self.reactor.set_round_templated(self.stage)
|
||||||
#print(self.reactor.procession)
|
|
||||||
self.reactor.forward()
|
self.reactor.forward()
|
||||||
|
self.compo = next(self.reactor.current_appar)
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header(show_clock=True)
|
yield Header(show_clock=True)
|
||||||
with Container(id="main_container"):
|
with Center():
|
||||||
yield Label(self.reactor.round_title, id="round_title")
|
yield Static(
|
||||||
yield Label("记住了吗?", id="question")
|
f"{len(self.reactor.procession) - self.reactor.index}/{len(self.reactor.procession)}"
|
||||||
yield Static(self.reactor.current_atom[1].content, id="sentence")
|
)
|
||||||
yield Static("", id="feedback") # 用于显示反馈
|
yield from self.compo.compose()
|
||||||
yield Label(self._get_progress_text(), id="progress")
|
|
||||||
with Container(id="button_container"):
|
|
||||||
if 1:
|
|
||||||
self.btn['5'] = Button("完美回想", variant="success", id="q5", classes="choice")
|
|
||||||
self.btn['4'] = Button("犹豫后正确", variant="success", id="q4", classes="choice")
|
|
||||||
self.btn['3'] = Button("困难地正确", variant="warning", id="q3", classes="choice")
|
|
||||||
self.btn['2'] = Button("错误但熟悉", variant="warning", id="q2", classes="choice")
|
|
||||||
self.btn['1'] = Button("错误且不熟", variant="error", id="q1", classes="choice")
|
|
||||||
self.btn['0'] = Button("完全空白", variant="error", id="q0", classes="choice")
|
|
||||||
yield Horizontal(self.btn['5'], self.btn['4'])
|
|
||||||
yield Horizontal(self.btn['3'], self.btn['2'])
|
|
||||||
yield Horizontal(self.btn['1'], self.btn['0'])
|
|
||||||
yield Footer()
|
yield Footer()
|
||||||
|
|
||||||
|
|
||||||
def _get_progress_text(self):
|
|
||||||
return f"{len(self.reactor.procession) - self.reactor.index}/{len(self.reactor.procession)}"
|
|
||||||
|
|
||||||
def on_mount(self):
|
def on_mount(self):
|
||||||
# 首次挂载时调用
|
pass
|
||||||
self._update_ui()
|
|
||||||
|
|
||||||
def _update_ui(self):
|
|
||||||
self.query_one("#round_title", Label).update(self.reactor.round_title)
|
|
||||||
self.query_one("#sentence", Static).update(self.reactor.current_atom[1].content)
|
|
||||||
self.query_one("#progress", Label).update(self._get_progress_text())
|
|
||||||
self.query_one("#feedback", Static).update("") # 清除任何之前的反馈消息
|
|
||||||
|
|
||||||
def _show_finished_screen(self, message):
|
|
||||||
self.query_one("#question", Label).update(message)
|
|
||||||
self.query_one("#sentence", Static).update("已经完成记忆任务")
|
|
||||||
self.query_one("#round_title").display = False
|
|
||||||
self.query_one("#progress").display = False
|
|
||||||
for i in range(6):
|
|
||||||
self.query_one(f"#q{i}", Button).display = False
|
|
||||||
|
|
||||||
def on_button_pressed(self, event):
|
def on_button_pressed(self, event):
|
||||||
feedback_label = self.query_one("#feedback", Static)
|
ret = self.compo.handler(event, "button")
|
||||||
if type(event) == str:
|
self._forward_judge(ret)
|
||||||
btnid = event
|
|
||||||
else:
|
def _forward_judge(self, ret):
|
||||||
btnid = event.button.id
|
if ret == -1:
|
||||||
btnid = str(btnid)
|
return
|
||||||
quality = int(btnid.replace('q', ''))
|
if ret == 0:
|
||||||
|
try:
|
||||||
|
self.compo = next(self.reactor.current_appar)
|
||||||
|
self.refresh_ui()
|
||||||
|
except StopIteration:
|
||||||
|
nxt = self.reactor.forward(1)
|
||||||
|
try:
|
||||||
|
self.compo = next(self.reactor.current_appar)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if nxt == -1:
|
||||||
|
if self.reactor.round_set == 0:
|
||||||
|
if self.stage == 4:
|
||||||
|
if config.get("save"):
|
||||||
|
self.reactor.save()
|
||||||
|
self.compo = compo.Finished(
|
||||||
|
self, None, pt.Atom.placeholder()
|
||||||
|
)
|
||||||
|
self.refresh_ui()
|
||||||
|
else:
|
||||||
|
self.reactor.set_round_templated(self.stage)
|
||||||
|
self.reactor.forward(1)
|
||||||
|
self.stage += 1
|
||||||
|
self.compo = next(self.reactor.current_appar)
|
||||||
|
self.refresh_ui()
|
||||||
|
return
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.refresh_ui()
|
||||||
|
return
|
||||||
|
if ret == 1:
|
||||||
|
self.refresh_ui()
|
||||||
|
return
|
||||||
|
|
||||||
|
def refresh_ui(self):
|
||||||
|
self.call_later(self.recompose)
|
||||||
|
|
||||||
|
def report(self, quality):
|
||||||
assessment = self.reactor.report(self.reactor.current_atom, quality)
|
assessment = self.reactor.report(self.reactor.current_atom, quality)
|
||||||
if assessment == 1:
|
return assessment
|
||||||
# 需要复习
|
|
||||||
feedback_label.update(f"评分为 {quality}, 已经加入至复习, 请重复记忆")
|
|
||||||
else:
|
|
||||||
ret = self.reactor.forward(1)
|
|
||||||
if ret == -1:
|
|
||||||
if self.reactor.round_set == 0:
|
|
||||||
if self.stage == 4:
|
|
||||||
# NOTE #
|
|
||||||
if config.get("save"):
|
|
||||||
self.reactor.save()
|
|
||||||
self._show_finished_screen("今日目标已完成")
|
|
||||||
else:
|
|
||||||
self.reactor.set_round_templated(self.stage)
|
|
||||||
self.reactor.forward(1)
|
|
||||||
self._update_ui()
|
|
||||||
self.stage += 1
|
|
||||||
return
|
|
||||||
#feedback_label.update("") # 清除反馈消息
|
|
||||||
self._update_ui()
|
|
||||||
def action_press(self, btnid):
|
|
||||||
self.on_button_pressed(btnid)
|
|
||||||
|
|
||||||
def action_play_voice(self):
|
def action_play_voice(self):
|
||||||
def play():
|
def play():
|
||||||
cache_dir = pathlib.Path(f"./cache/voice/")
|
cache_dir = pathlib.Path(f"./cache/voice/")
|
||||||
cache_dir.mkdir(parents = True, exist_ok = True)
|
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():
|
if not cache.exists():
|
||||||
communicate = tts.Communicate(self.reactor.current_atom[1].content, "zh-CN-YunjianNeural")
|
communicate = tts.Communicate(
|
||||||
communicate.save_sync(f"./cache/voice/{self.reactor.current_atom[1].content}.wav")
|
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))
|
playsound(str(cache))
|
||||||
|
|
||||||
threading.Thread(target=play).start()
|
threading.Thread(target=play).start()
|
||||||
|
|
||||||
def action_toggle_dark(self):
|
def action_toggle_dark(self):
|
||||||
self.app.action_toggle_dark()
|
self.app.action_toggle_dark()
|
||||||
|
|
||||||
def action_pop_screen(self):
|
def action_pop_screen(self):
|
||||||
"""返回到上一个屏幕"""
|
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
|
|
||||||
class PreparationScreen(Screen):
|
|
||||||
BINDINGS = [
|
|
||||||
("q", "go_back", "返回"),
|
|
||||||
("escape", "quit_app", "退出")
|
|
||||||
]
|
|
||||||
|
|
||||||
def __init__(self, nucleon_file: pt.NucleonUnion, electron_file: pt.ElectronUnion) -> None:
|
class PreparationScreen(Screen):
|
||||||
|
BINDINGS = [("q", "go_back", "返回"), ("escape", "quit_app", "退出")]
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, nucleon_file: pt.NucleonUnion, electron_file: pt.ElectronUnion
|
||||||
|
) -> None:
|
||||||
super().__init__(name=None, id=None, classes=None)
|
super().__init__(name=None, id=None, classes=None)
|
||||||
self.nucleon_file = nucleon_file
|
self.nucleon_file = nucleon_file
|
||||||
self.electron_file = electron_file
|
self.electron_file = electron_file
|
||||||
@@ -156,10 +169,19 @@ class PreparationScreen(Screen):
|
|||||||
yield Header(show_clock=True)
|
yield Header(show_clock=True)
|
||||||
with Container(id="learning_screen_container"):
|
with Container(id="learning_screen_container"):
|
||||||
yield Label(f"记忆项目: [b]{self.nucleon_file.name}[/b]\n")
|
yield Label(f"记忆项目: [b]{self.nucleon_file.name}[/b]\n")
|
||||||
yield Label(f"核子文件对象: ./nucleon/[b]{self.nucleon_file.name}[/b].toml")
|
yield Label(
|
||||||
yield Label(f"电子文件对象: ./electron/[b]{self.electron_file.name}[/b].toml")
|
f"核子文件对象: ./nucleon/[b]{self.nucleon_file.name}[/b].toml"
|
||||||
|
)
|
||||||
|
yield Label(
|
||||||
|
f"电子文件对象: ./electron/[b]{self.electron_file.name}[/b].toml"
|
||||||
|
)
|
||||||
yield Label(f"核子数量:{len(self.nucleon_file)}")
|
yield Label(f"核子数量:{len(self.nucleon_file)}")
|
||||||
yield Button("开始记忆", id="start_memorizing_button", variant="primary", classes="start-button")
|
yield Button(
|
||||||
|
"开始记忆",
|
||||||
|
id="start_memorizing_button",
|
||||||
|
variant="primary",
|
||||||
|
classes="start-button",
|
||||||
|
)
|
||||||
yield Static(f"\n全文如下:\n")
|
yield Static(f"\n全文如下:\n")
|
||||||
yield Static(self._get_full_content(), classes="full")
|
yield Static(self._get_full_content(), classes="full")
|
||||||
yield Footer()
|
yield Footer()
|
||||||
@@ -167,7 +189,7 @@ class PreparationScreen(Screen):
|
|||||||
def _get_full_content(self):
|
def _get_full_content(self):
|
||||||
content = ""
|
content = ""
|
||||||
for i in self.nucleon_file.nucleons:
|
for i in self.nucleon_file.nucleons:
|
||||||
content += i['content']
|
content += i["content"]
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def action_go_back(self):
|
def action_go_back(self):
|
||||||
@@ -177,76 +199,79 @@ class PreparationScreen(Screen):
|
|||||||
self.app.exit()
|
self.app.exit()
|
||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
pass
|
|
||||||
if event.button.id == "start_memorizing_button":
|
if event.button.id == "start_memorizing_button":
|
||||||
#init_file(Path(self.atom_file).name)
|
newscr = MemScreen(
|
||||||
newscr = MemScreen(self.nucleon_file, self.electron_file, config.get("tasked_number", 8))
|
self.nucleon_file, self.electron_file, config.get("tasked_number", 8)
|
||||||
self.app.push_screen(
|
|
||||||
newscr
|
|
||||||
)
|
)
|
||||||
#if event.button.id == "edit_metadata_button":
|
self.app.push_screen(newscr)
|
||||||
# init_file(Path(self.atom_file).name)
|
|
||||||
# os.system("reset;nano ./data/" + str(Path(self.atom_file).name.replace(".txt", "_atoms.json")))
|
|
||||||
|
|
||||||
class FileSelectorScreen(Screen):
|
class FileSelectorScreen(Screen):
|
||||||
global ver
|
global ver
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header(show_clock=True)
|
yield Header(show_clock=True)
|
||||||
yield Container(
|
yield Container(
|
||||||
Label(f'欢迎使用 "潜进" 辅助记忆软件, 版本 {ver}', classes="title-label"),
|
Label(f'欢迎使用 "潜进" 辅助记忆软件, 版本 {ver}', classes="title-label"),
|
||||||
Label("选择要学习的文件:", classes="title-label"),
|
Label("选择要学习的文件:", classes="title-label"),
|
||||||
ListView(id="file-list", classes="file-list-view")
|
ListView(id="file-list", classes="file-list-view"),
|
||||||
)
|
)
|
||||||
yield Footer()
|
yield Footer()
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
file_list_widget = self.query_one("#file-list", ListView)
|
file_list_widget = self.query_one("#file-list", ListView)
|
||||||
nucleon_path = pathlib.Path("./nucleon")
|
nucleon_path = pathlib.Path("./nucleon")
|
||||||
nucleon_files = sorted([f.name for f in nucleon_path.iterdir() if f.suffix == ".toml"])
|
nucleon_files = sorted(
|
||||||
|
[f.name for f in nucleon_path.iterdir() if f.suffix == ".toml"]
|
||||||
|
)
|
||||||
|
|
||||||
if nucleon_files:
|
if nucleon_files:
|
||||||
for filename in nucleon_files:
|
for filename in nucleon_files:
|
||||||
file_list_widget.append(ListItem(Label(filename)))
|
file_list_widget.append(ListItem(Label(filename)))
|
||||||
else:
|
else:
|
||||||
file_list_widget.append(ListItem(Static("在 ./nucleon/ 中未找到任何核子文件. 请放置文件后重启应用.")))
|
file_list_widget.append(
|
||||||
|
ListItem(Static("在 ./nucleon/ 中未找到任何核子文件. 请放置文件后重启应用."))
|
||||||
|
)
|
||||||
file_list_widget.disabled = True
|
file_list_widget.disabled = True
|
||||||
|
|
||||||
def on_list_view_selected(self, event: ListView.Selected) -> None:
|
def on_list_view_selected(self, event: ListView.Selected) -> None:
|
||||||
if not isinstance(event.item, ListItem):
|
if not isinstance(event.item, ListItem):
|
||||||
self.notify("无法选择此项。", severity="error")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
selected_label = event.item.query_one(Label)
|
selected_label = event.item.query_one(Label)
|
||||||
if "未找到任何 .toml 文件" in str(selected_label.renderable):
|
if "未找到任何 .toml 文件" in str(selected_label.renderable):
|
||||||
self.notify("请先在 `./atoms/` 目录中放置 .toml 文件。", severity="warning")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
selected_filename = str(selected_label.renderable)
|
selected_filename = str(selected_label.renderable)
|
||||||
nucleon_file = pt.NucleonUnion(pathlib.Path("./nucleon") / selected_filename)
|
nucleon_file = pt.NucleonUnion(
|
||||||
|
pathlib.Path("./nucleon") / selected_filename
|
||||||
|
)
|
||||||
electron_file_path = pathlib.Path("./electron") / selected_filename
|
electron_file_path = pathlib.Path("./electron") / selected_filename
|
||||||
if electron_file_path.exists():
|
if electron_file_path.exists():
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
electron_file_path.touch()
|
electron_file_path.touch()
|
||||||
electron_file = pt.ElectronUnion(pathlib.Path("./electron") / selected_filename)
|
electron_file = pt.ElectronUnion(
|
||||||
# self.notify(f"已选择: {selected_filename}", timeout=2)
|
pathlib.Path("./electron") / selected_filename
|
||||||
|
)
|
||||||
self.app.push_screen(PreparationScreen(nucleon_file, electron_file))
|
self.app.push_screen(PreparationScreen(nucleon_file, electron_file))
|
||||||
|
|
||||||
def action_quit_app(self) -> None:
|
def action_quit_app(self) -> None:
|
||||||
self.app.exit()
|
self.app.exit()
|
||||||
|
|
||||||
|
|
||||||
class AppLauncher(App):
|
class AppLauncher(App):
|
||||||
CSS_PATH = "styles.tcss"
|
CSS_PATH = "styles.tcss"
|
||||||
TITLE = '潜进 - 辅助记忆程序'
|
TITLE = "潜进 - 辅助记忆程序"
|
||||||
BINDINGS = [("escape", "quit", "退出"), ("d", "toggle_dark", "改变色调")]
|
BINDINGS = [("escape", "quit", "退出"), ("d", "toggle_dark", "改变色调")]
|
||||||
SCREENS = {
|
SCREENS = {
|
||||||
"file_selection_screen": FileSelectorScreen,
|
"file_selection_screen": FileSelectorScreen,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self.action_toggle_dark()
|
|
||||||
self.push_screen("file_selection_screen")
|
self.push_screen("file_selection_screen")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = AppLauncher()
|
app = AppLauncher()
|
||||||
app.run()
|
app.run()
|
230
nucleon/陈情表.toml
230
nucleon/陈情表.toml
@@ -7,148 +7,148 @@ translation = "语句翻译"
|
|||||||
# 测试项目元数据
|
# 测试项目元数据
|
||||||
["testdata"]
|
["testdata"]
|
||||||
# 记忆时显示的额外信息
|
# 记忆时显示的额外信息
|
||||||
additional_inf = ["translation", "note"]
|
additional_inf = ["translation","keyword_note", "note"]
|
||||||
# 填空测试
|
# 填空测试, content指代键名
|
||||||
fill_blank = ["translation"]
|
fill_blank_test = {"from"=["content"], "hint"=["translation"]}
|
||||||
# 选择题测试
|
# 选择题测试
|
||||||
draw_card = ["keyword_note"]
|
draw_card_test = {"from"=["keyword_note"]}
|
||||||
|
|
||||||
["臣密言:臣以险衅, 夙遭闵凶."]
|
["臣/密/言: /臣/以/险衅/, 夙/遭/闵凶./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "臣子李密陈言:我因命运不好,小时候遭遇到了不幸"
|
translation = "臣子李密陈言: 我因命运不好, 小时候遭遇到了不幸"
|
||||||
keyword_note = {"险衅"="凶险祸患(这里指命运不好)", "夙"="早时,这里指年幼的时候", "闵"="通'悯',指可忧患的事", "凶"="不幸,指丧父"}
|
keyword_note = {"险衅"="凶险祸患(这里指命运不好)", "夙"="早时, 这里指年幼的时候", "闵"="通'悯', 指可忧患的事", "凶"="不幸, 指丧父"}
|
||||||
|
|
||||||
["生孩六月, 慈父见背;行年四岁, 舅夺母志."]
|
["生孩/六月/, 慈父/见背/; /行年/四岁/, 舅/夺/母志./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "刚出生六个月,我慈爱的父亲就不幸去世了。经过了四年,舅父逼母亲改嫁"
|
translation = "刚出生六个月, 我慈爱的父亲就不幸去世了。经过了四年, 舅父逼母亲改嫁"
|
||||||
keyword_note = {"见背"="死的委婉说法", "行年"="经历的年岁", "母志"="母亲守节之志(改嫁的委婉说法)"}
|
keyword_note = {"见背"="死的委婉说法", "行年"="经历的年岁", "母志"="母亲守节之志(改嫁的委婉说法)"}
|
||||||
|
|
||||||
["祖母刘愍臣孤弱, 躬亲抚养."]
|
["祖母/刘/愍/臣/孤弱/, 躬亲/抚养./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我的祖母刘氏,怜悯我从小丧父,便亲自对我加以抚养"
|
translation = "我的祖母刘氏, 怜悯我从小丧父, 便亲自对我加以抚养"
|
||||||
keyword_note = {"愍"="怜悯", "躬亲"="亲身"}
|
keyword_note = {"愍"="怜悯", "躬亲"="亲身"}
|
||||||
|
|
||||||
["臣少多疾病, 九岁不行, 零丁孤苦, 至于成立."]
|
["臣/少/多/疾病/, 九岁/不行/, 零丁/孤苦/, 至于/成立./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "臣小的时候经常生病,九岁时还不会行走。孤独无靠,一直到成人自立"
|
translation = "臣小的时候经常生病, 九岁时还不会行走。孤独无靠, 一直到成人自立"
|
||||||
keyword_note = {"成立"="成人自立"}
|
keyword_note = {"成立"="成人自立"}
|
||||||
|
|
||||||
["既无伯叔, 终鲜兄弟, 门衰祚薄, 晚有儿息."]
|
["既/无/伯叔/, 终/鲜/兄弟/, 门/衰/祚/薄/, 晚/有/儿息./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "既没有叔叔伯伯,又没什么兄弟,门庭衰微而福分浅薄,很晚才有儿子"
|
translation = "既没有叔叔伯伯, 又没什么兄弟, 门庭衰微而福分浅薄, 很晚才有儿子"
|
||||||
keyword_note = {"鲜"="少,这里指'无'", "祚薄"="福分浅薄", "儿息"="亲生子女"}
|
keyword_note = {"鲜"="少, 这里指'无'", "祚薄"="福分浅薄", "儿息"="亲生子女"}
|
||||||
|
|
||||||
["外无期功强近之亲, 内无应门五尺之僮, 茕茕孑立, 形影相吊."]
|
["外/无/期功/强近/之亲/, 内/无/应门/五尺/之僮/, 茕茕/孑立/, 形影/相吊./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "在外面没有比较亲近的亲戚,在家里又没有照应门户的童仆。生活孤单没有依靠,每天只有自己的身体和影子相互安慰"
|
translation = "在外面没有比较亲近的亲戚, 在家里又没有照应门户的童仆。生活孤单没有依靠, 每天只有自己的身体和影子相互安慰"
|
||||||
keyword_note = {"期功"="指关系较近的亲属", "茕茕孑立"="孤单无依靠的样子", "吊"="安慰"}
|
keyword_note = {"期功"="指关系较近的亲属", "茕茕孑立"="孤单无依靠的样子", "吊"="安慰"}
|
||||||
|
|
||||||
["而刘夙婴疾病, 常在床蓐, 臣侍汤药, 未曾废离."]
|
["而/刘/夙/婴/疾病/, 常/在/床蓐/, 臣/侍/汤药/, 未曾/废离./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "但祖母又早被疾病缠绕,常年卧床不起,我侍奉她吃饭喝药,从来就没有停止侍奉而离开她"
|
translation = "但祖母又早被疾病缠绕, 常年卧床不起, 我侍奉她吃饭喝药, 从来就没有停止侍奉而离开她"
|
||||||
keyword_note = {"婴"="被...缠绕", "蓐"="通'褥',床垫", "废"="停止服侍", "离"="离开"}
|
keyword_note = {"婴"="被...缠绕", "蓐"="通'褥', 床垫", "废"="停止服侍", "离"="离开"}
|
||||||
|
|
||||||
["逮奉圣朝, 沐浴清化."]
|
["逮/奉/圣朝/, 沐浴/清化./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "到了晋朝建立,我蒙受着清明的政治教化"
|
translation = "到了晋朝建立, 我蒙受着清明的政治教化"
|
||||||
keyword_note = {"逮"="及,到", "奉"="承奉", "圣朝"="指当时的晋朝", "沐浴清化"="蒙受清平教化"}
|
keyword_note = {"逮"="及, 到", "奉"="承奉", "圣朝"="指当时的晋朝", "沐浴清化"="蒙受清平教化"}
|
||||||
|
|
||||||
["前太守臣逵察臣孝廉;后刺史臣荣举臣秀才."]
|
["前/太守/臣/逵/察/臣/孝廉/; /后/刺史/臣/荣/举/臣/秀才./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "前任太守逵,考察后推举臣下为孝廉,后任刺史荣又推举臣下为优秀人才"
|
translation = "前任太守逵, 考察后推举臣下为孝廉, 后任刺史荣又推举臣下为优秀人才"
|
||||||
keyword_note = {"察"="考察和推举", "孝廉"="孝顺,品性纯洁", "举"="推举", "秀才"="优秀人才"}
|
keyword_note = {"察"="考察和推举", "孝廉"="孝顺, 品性纯洁", "举"="推举", "秀才"="优秀人才"}
|
||||||
|
|
||||||
["臣以供养无主, 辞不赴命."]
|
["臣/以/供养/无主/, 辞/不赴命./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "臣下因为供奉赡养祖母的事无人承担,辞谢不接受任命"
|
translation = "臣下因为供奉赡养祖母的事无人承担, 辞谢不接受任命"
|
||||||
keyword_note = {"无主"="无人承担"}
|
keyword_note = {"无主"="无人承担"}
|
||||||
|
|
||||||
["诏书特下, 拜臣郎中, 寻蒙国恩, 除臣洗马."]
|
["诏书/特下/, 拜/臣/郎中/, 寻/蒙/国恩/, 除/臣/洗马./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "朝廷又特地下了诏书,任命我为郎中,不久又蒙受国家恩命,任命我为太子洗马"
|
translation = "朝廷又特地下了诏书, 任命我为郎中, 不久又蒙受国家恩命, 任命我为太子洗马"
|
||||||
keyword_note = {"拜"="授予官职", "郎中"="尚书省的属官", "寻"="不久", "除"="拜官受职", "洗马"="太子的属官"}
|
keyword_note = {"拜"="授予官职", "郎中"="尚书省的属官", "寻"="不久", "除"="拜官受职", "洗马"="太子的属官"}
|
||||||
|
|
||||||
["猥以微贱, 当侍东宫, 非臣陨首所能上报."]
|
["猥/以/微贱/, 当/侍/东宫/, 非/臣/陨首/所能/上报./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "像我这样出身微贱地位卑下的人,担当侍奉太子的职务,这实在不是我杀身捐躯所能报答朝廷的"
|
translation = "像我这样出身微贱地位卑下的人, 担当侍奉太子的职务, 这实在不是我杀身捐躯所能报答朝廷的"
|
||||||
keyword_note = {"猥"="谦词", "微贱"="卑微低贱", "东宫"="太子居处", "陨首"="杀身"}
|
keyword_note = {"猥"="谦词", "微贱"="卑微低贱", "东宫"="太子居处", "陨首"="杀身"}
|
||||||
|
|
||||||
["臣具以表闻, 辞不就职."]
|
["臣/具/以表/闻/, 辞/不就职./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我将以上苦衷上表报告,加以推辞不去就职"
|
translation = "我将以上苦衷上表报告, 加以推辞不去就职"
|
||||||
keyword_note = {"具"="详细", "闻"="使...知道"}
|
keyword_note = {"具"="详细", "闻"="使...知道"}
|
||||||
|
|
||||||
["诏书切峻, 责臣逋慢;郡县逼迫, 催臣上道;州司临门, 急于星火."]
|
["诏书/切峻/, 责/臣/逋慢/; /郡县/逼迫/, 催/臣/上道/; /州司/临门/, 急于/星火./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "但是诏书急切严峻,责备我逃避命令,有意拖延,态度傲慢。郡县长官催促我立刻上路;州官登门督促,比流星坠落还要急迫"
|
translation = "但是诏书急切严峻, 责备我逃避命令, 有意拖延, 态度傲慢。郡县长官催促我立刻上路; 州官登门督促, 比流星坠落还要急迫"
|
||||||
keyword_note = {"切峻"="急切而严厉", "逋慢"="逃避怠慢", "星火"="流星的光,喻急迫"}
|
keyword_note = {"切峻"="急切而严厉", "逋慢"="逃避怠慢", "星火"="流星的光, 喻急迫"}
|
||||||
|
|
||||||
["臣欲奉诏奔驰, 则刘病日笃, 欲苟顺私情, 则告诉不许."]
|
["臣/欲/奉诏/奔驰/, 则/刘/病/日笃/, 欲/苟/顺/私情/, 则/告诉/不许./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我很想遵从皇上的旨意赴京就职,但祖母刘氏的病却一天比一天重;想要姑且顺从自己的私情,但报告申诉不被允许"
|
translation = "我很想遵从皇上的旨意赴京就职, 但祖母刘氏的病却一天比一天重; 想要姑且顺从自己的私情, 但报告申诉不被允许"
|
||||||
keyword_note = {"日笃"="病情日益加重", "苟"="姑且", "告诉"="报告申诉"}
|
keyword_note = {"日笃"="病情日益加重", "苟"="姑且", "告诉"="报告申诉"}
|
||||||
|
|
||||||
["臣之进退, 实为狼狈."]
|
["臣/之/进退/, 实为/狼狈./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我是进退两难,十分狼狈"
|
translation = "我是进退两难, 十分狼狈"
|
||||||
keyword_note = {"狼狈"="进退两难的样子"}
|
keyword_note = {"狼狈"="进退两难的样子"}
|
||||||
|
|
||||||
["伏惟圣朝以孝治天下, 凡在故老, 犹蒙矜育, 况臣孤苦, 特为尤甚."]
|
["伏惟/圣朝/以/孝/治/天下/, 凡/在/故老/, 犹/蒙/矜育/, 况/臣/孤苦/, 特为/尤甚./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我俯伏思量晋朝是用孝道来治理天下的,凡是年老而德高的旧臣,尚且还受到怜悯养育,何况我的孤苦程度更为严重呢"
|
translation = "我俯伏思量晋朝是用孝道来治理天下的, 凡是年老而德高的旧臣, 尚且还受到怜悯养育, 何况我的孤苦程度更为严重呢"
|
||||||
keyword_note = {"伏惟"="下对上的敬辞", "故老"="年老德高的旧臣", "矜育"="怜悯养育"}
|
keyword_note = {"伏惟"="下对上的敬辞", "故老"="年老德高的旧臣", "矜育"="怜悯养育"}
|
||||||
|
|
||||||
["且臣少仕伪朝, 历职郎署, 本图宦达, 不矜名节."]
|
["且/臣/少/仕/伪朝/, 历职/郎署/, 本图/宦达/, 不矜/名节./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "况且我年轻的时候曾经做过蜀汉的官,担任过郎官职务,本来就希望做官显达,并不顾惜名声节操"
|
translation = "况且我年轻的时候曾经做过蜀汉的官, 担任过郎官职务, 本来就希望做官显达, 并不顾惜名声节操"
|
||||||
keyword_note = {"伪朝"="对前朝的蔑称", "历职"="连续任职", "郎署"="尚书郎的官衙", "宦达"="官场上显达"}
|
keyword_note = {"伪朝"="对前朝的蔑称", "历职"="连续任职", "郎署"="尚书郎的官衙", "宦达"="官场上显达"}
|
||||||
|
|
||||||
["今臣亡国贱俘, 至微至陋, 过蒙拔擢, 宠命优渥, 岂敢盘桓, 有所希冀!"]
|
["今/臣/亡国/贱俘/, 至微/至陋/, 过/蒙/拔擢/, 宠命/优渥/, 岂敢/盘桓/, 有所/希冀!/"]
|
||||||
note = []
|
note = []
|
||||||
translation = "现在我是一个低贱的亡国俘虏,十分卑微浅陋,受到过分提拔,恩宠优厚,怎敢犹豫不决而有非分的企求呢"
|
translation = "现在我是一个低贱的亡国俘虏, 十分卑微浅陋, 受到过分提拔, 恩宠优厚, 怎敢犹豫不决而有非分的企求呢"
|
||||||
keyword_note = {"拔擢"="提拔", "优渥"="优厚", "盘桓"="徘徊不前", "希冀"="非分的企求"}
|
keyword_note = {"拔擢"="提拔", "优渥"="优厚", "盘桓"="徘徊不前", "希冀"="非分的企求"}
|
||||||
|
|
||||||
["但以刘日薄西山, 气息奄奄, 人命危浅, 朝不虑夕."]
|
["但/以/刘/日薄/西山/, 气息/奄奄/, 人命/危浅/, 朝不/虑夕./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "只是因为祖母刘氏寿命即将终了,气息微弱,生命垂危,早上不能想到晚上怎样"
|
translation = "只是因为祖母刘氏寿命即将终了, 气息微弱, 生命垂危, 早上不能想到晚上怎样"
|
||||||
keyword_note = {"日薄西山"="太阳接近西山,喻人寿命将终", "危浅"="生命垂危"}
|
keyword_note = {"日薄西山"="太阳接近西山, 喻人寿命将终", "危浅"="生命垂危"}
|
||||||
|
|
||||||
["臣无祖母, 无以至今日, 祖母无臣, 无以终余年."]
|
["臣/无/祖母/, 无以/至今日/, 祖母/无/臣/, 无以/终余年./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "臣下我如果没有祖母,就没有今天的样子;祖母如果没有我的照料,也无法度过她的余生"
|
translation = "臣下我如果没有祖母, 就没有今天的样子; 祖母如果没有我的照料, 也无法度过她的余生"
|
||||||
keyword_note = {"终余年"="度过余生"}
|
keyword_note = {"终余年"="度过余生"}
|
||||||
|
|
||||||
["母孙二人, 更相为命, 是以区区不能废远."]
|
["母孙/二人/, 更相/为命/, 是以/区区/不能/废远./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我们祖孙二人,互相依靠而维持生命,因此我的内心不愿废止奉养,远离祖母"
|
translation = "我们祖孙二人, 互相依靠而维持生命, 因此我的内心不愿废止奉养, 远离祖母"
|
||||||
keyword_note = {"更相"="相互", "区区"="自己的私情", "废远"="废止奉养而远离"}
|
keyword_note = {"更相"="相互", "区区"="自己的私情", "废远"="废止奉养而远离"}
|
||||||
|
|
||||||
["臣密今年四十有四, 祖母今年九十有六, 是臣尽节于陛下之日长, 报养刘之日短."]
|
["臣/密/今年/四十/有四/, 祖母/今年/九十/有六/, 是/臣/尽节/于/陛下/之日/长/, 报养/刘/之日/短./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "臣下我现在的年龄四十四岁了,祖母现在的年龄九十六岁了,臣下我在陛下面前尽忠尽节的日子还长着呢,而在祖母刘氏面前尽孝尽心的日子已经不多了"
|
translation = "臣下我现在的年龄四十四岁了, 祖母现在的年龄九十六岁了, 臣下我在陛下面前尽忠尽节的日子还长着呢, 而在祖母刘氏面前尽孝尽心的日子已经不多了"
|
||||||
keyword_note = {"有"="又", "尽节"="尽忠节"}
|
keyword_note = {"有"="又", "尽节"="尽忠节"}
|
||||||
|
|
||||||
["乌鸟私情, 愿乞终养."]
|
["乌鸟/私情/, 愿/乞/终养./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我怀着乌鸦反哺的私情,乞求能够准许我完成对祖母养老送终的心愿"
|
translation = "我怀着乌鸦反哺的私情, 乞求能够准许我完成对祖母养老送终的心愿"
|
||||||
keyword_note = {"乌鸟私情"="乌鸦反哺之情,喻孝心", "终养"="养老至终"}
|
keyword_note = {"乌鸟私情"="乌鸦反哺之情, 喻孝心", "终养"="养老至终"}
|
||||||
|
|
||||||
["臣之辛苦, 非独蜀之人士及二州牧伯所见明知, 皇天后土, 实所共鉴."]
|
["臣/之/辛苦/, 非独/蜀之/人士/及/二州/牧伯/所见/明知/, 皇天/后土/, 实所/共鉴./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我的辛酸苦楚,并不仅仅被蜀地的百姓及益州、梁州的长官所亲眼目睹、内心明白,连天地神明也都看得清清楚楚"
|
translation = "我的辛酸苦楚, 并不仅仅被蜀地的百姓及益州、梁州的长官所亲眼目睹、内心明白, 连天地神明也都看得清清楚楚"
|
||||||
keyword_note = {"辛苦"="辛酸苦楚", "牧伯"="州郡长官", "皇天后土"="天地神明", "鉴"="明察"}
|
keyword_note = {"辛苦"="辛酸苦楚", "牧伯"="州郡长官", "皇天后土"="天地神明", "鉴"="明察"}
|
||||||
|
|
||||||
["愿陛下矜悯愚诚, 听臣微志, 庶刘侥幸, 保卒余年."]
|
["愿/陛下/矜悯/愚诚/, 听/臣/微志/, 庶/刘/侥幸/, 保/卒/余年./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "希望陛下能怜悯我愚昧诚心,请允许我完成臣下一点小小的心愿,使祖母刘氏能够侥幸地保全她的余生"
|
translation = "希望陛下能怜悯我愚昧诚心, 请允许我完成臣下一点小小的心愿, 使祖母刘氏能够侥幸地保全她的余生"
|
||||||
keyword_note = {"矜悯"="怜悯", "听"="准许", "庶"="或许(表希望)", "卒余年"="终老"}
|
keyword_note = {"矜悯"="怜悯", "听"="准许", "庶"="或许(表希望)", "卒余年"="终老"}
|
||||||
|
|
||||||
["臣生当陨首, 死当结草."]
|
["臣/生/当/陨首/, 死/当/结草./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "我活着应当杀身报效朝廷,死了也要结草衔环来报答陛下的恩情"
|
translation = "我活着应当杀身报效朝廷, 死了也要结草衔环来报答陛下的恩情"
|
||||||
keyword_note = {"陨首"="掉脑袋,指献出生命", "结草"="死后报恩的典故"}
|
keyword_note = {"陨首"="掉脑袋, 指献出生命", "结草"="死后报恩的典故"}
|
||||||
|
|
||||||
["臣不胜犬马怖惧之情, 谨拜表以闻."]
|
["臣/不胜/犬马/怖惧/之情/, 谨/拜表/以闻./"]
|
||||||
note = []
|
note = []
|
||||||
translation = "臣下我怀着牛马一样不胜恐惧的心情,恭敬地呈上此表来使陛下知道这件事"
|
translation = "臣下我怀着牛马一样不胜恐惧的心情, 恭敬地呈上此表来使陛下知道这件事"
|
||||||
keyword_note = {"不胜"="禁不住", "犬马怖惧"="臣子谦卑的自比", "闻"="使...知道"}
|
keyword_note = {"不胜"="禁不住", "犬马怖惧"="臣子谦卑的自比", "闻"="使...知道"}
|
140
particles.py
140
particles.py
@@ -3,37 +3,36 @@ import toml
|
|||||||
import time
|
import time
|
||||||
import auxiliary as aux
|
import auxiliary as aux
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
class Electron():
|
class Electron:
|
||||||
"""电子: 记忆分析元数据及算法"""
|
"""电子: 记忆分析元数据及算法"""
|
||||||
algorithm = "SM-2" # 暂时使用 SM-2 算法进行记忆拟合, 考虑 SM-15 替代
|
algorithm = "SM-2" # 暂时使用 SM-2 算法进行记忆拟合, 考虑 SM-15 替代
|
||||||
|
|
||||||
def __init__(self, content: str, metadata: dict):
|
def __init__(self, content: str, metadata: dict):
|
||||||
self.content = content
|
self.content = content
|
||||||
self.metadata = metadata
|
self.metadata = metadata
|
||||||
if metadata == {}:
|
if metadata == {}:
|
||||||
#print("NULL")
|
# print("NULL")
|
||||||
self._default_init()
|
self._default_init()
|
||||||
|
|
||||||
def _default_init(self):
|
def _default_init(self):
|
||||||
defaults = {
|
defaults = {
|
||||||
'efactor': 2.5, # 易度系数, 越大越简单, 最大为5
|
'efactor': 2.5, # 易度系数, 越大越简单, 最大为5
|
||||||
'real_rept': 0, # (实际)重复次数
|
'real_rept': 0, # (实际)重复次数
|
||||||
'rept': 0, # (有效)重复次数
|
'rept': 0, # (有效)重复次数
|
||||||
'interval': 0, # 最佳间隔
|
'interval': 0, # 最佳间隔
|
||||||
'last_date': 0, # 上一次复习的时间戳
|
'last_date': 0, # 上一次复习的时间戳
|
||||||
'next_date': 0, # 将要复习的时间戳
|
'next_date': 0, # 将要复习的时间戳
|
||||||
'is_activated': 0, # 激活状态
|
'is_activated': 0, # 激活状态
|
||||||
# *NOTE: 此处"时间戳"是以天为单位的整数, 即 UNIX 时间戳除以一天的秒数取整
|
# *NOTE: 此处"时间戳"是以天为单位的整数, 即 UNIX 时间戳除以一天的秒数取整
|
||||||
'last_modify': time.time() # 最后修改时间戳(此处是UNIX时间戳)
|
'last_modify': time.time() # 最后修改时间戳(此处是UNIX时间戳)
|
||||||
}
|
}
|
||||||
self.metadata = defaults
|
self.metadata = defaults
|
||||||
|
|
||||||
def activate(self):
|
def activate(self):
|
||||||
self.metadata['is_activated'] = 1
|
self.metadata['is_activated'] = 1
|
||||||
self.metadata['last_modify'] = time.time()
|
self.metadata['last_modify'] = time.time()
|
||||||
|
|
||||||
def modify(self, var: str, value):
|
def modify(self, var: str, value):
|
||||||
if var in self.metadata:
|
if var in self.metadata:
|
||||||
self.metadata[var] = value
|
self.metadata[var] = value
|
||||||
@@ -41,7 +40,7 @@ class Electron():
|
|||||||
else:
|
else:
|
||||||
print(f"警告: '{var}' 非已知元数据字段")
|
print(f"警告: '{var}' 非已知元数据字段")
|
||||||
|
|
||||||
def revisor(self, quality: int = 5, is_new_activation: bool = False):
|
def revisor(self, quality: int = 5, is_new_activation: bool = False):
|
||||||
"""SM-2 算法迭代决策机制实现
|
"""SM-2 算法迭代决策机制实现
|
||||||
根据 quality(0 ~ 5) 进行参数迭代最佳间隔
|
根据 quality(0 ~ 5) 进行参数迭代最佳间隔
|
||||||
quality 由主程序评估
|
quality 由主程序评估
|
||||||
@@ -51,41 +50,47 @@ class Electron():
|
|||||||
"""
|
"""
|
||||||
if quality == -1:
|
if quality == -1:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
self.metadata['efactor'] = self.metadata['efactor'] + (0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02))
|
self.metadata['efactor'] = self.metadata['efactor'] + (
|
||||||
|
0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02)
|
||||||
|
)
|
||||||
self.metadata['efactor'] = max(1.3, self.metadata['efactor'])
|
self.metadata['efactor'] = max(1.3, self.metadata['efactor'])
|
||||||
|
|
||||||
if quality < 3:
|
if quality < 3:
|
||||||
# 若保留率低于 3,重置重复次数
|
# 若保留率低于 3,重置重复次数
|
||||||
self.metadata['rept'] = 0
|
self.metadata['rept'] = 0
|
||||||
self.metadata['interval'] = 0 # 设为0,以便下面重新计算 I(1)
|
self.metadata['interval'] = 0 # 设为0,以便下面重新计算 I(1)
|
||||||
else:
|
else:
|
||||||
self.metadata['rept'] += 1
|
self.metadata['rept'] += 1
|
||||||
|
|
||||||
self.metadata['real_rept'] += 1
|
self.metadata['real_rept'] += 1
|
||||||
|
|
||||||
if is_new_activation: # 初次激活
|
if is_new_activation: # 初次激活
|
||||||
self.metadata['rept'] = 0
|
self.metadata['rept'] = 0
|
||||||
self.metadata['efactor'] = 2.5
|
self.metadata['efactor'] = 2.5
|
||||||
|
|
||||||
if self.metadata['rept'] == 0: # 刚被重置或初次激活后复习
|
if self.metadata['rept'] == 0: # 刚被重置或初次激活后复习
|
||||||
self.metadata['interval'] = 1 # I(1)
|
self.metadata['interval'] = 1 # I(1)
|
||||||
elif self.metadata['rept'] == 1:
|
elif self.metadata['rept'] == 1:
|
||||||
self.metadata['interval'] = 6 # I(2) 经验公式
|
self.metadata['interval'] = 6 # I(2) 经验公式
|
||||||
else:
|
else:
|
||||||
self.metadata['interval'] = round(self.metadata['interval'] * self.metadata['efactor'])
|
self.metadata['interval'] = round(
|
||||||
|
self.metadata['interval'] * self.metadata['efactor']
|
||||||
|
)
|
||||||
|
|
||||||
self.metadata['last_date'] = aux.get_daystamp()
|
self.metadata['last_date'] = aux.get_daystamp()
|
||||||
self.metadata['next_date'] = aux.get_daystamp() + self.metadata['interval']
|
self.metadata['next_date'] = aux.get_daystamp() + self.metadata['interval']
|
||||||
self.metadata['last_modify'] = time.time()
|
self.metadata['last_modify'] = time.time()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return (f"记忆单元预览 \n"
|
return (
|
||||||
f"内容: '{self.content}' \n"
|
f"记忆单元预览 \n"
|
||||||
f"易度系数: {self.metadata['efactor']:.2f} \n"
|
f"内容: '{self.content}' \n"
|
||||||
f"已经重复的次数: {self.metadata['rept']} \n"
|
f"易度系数: {self.metadata['efactor']:.2f} \n"
|
||||||
f"下次间隔: {self.metadata['interval']} 天 \n"
|
f"已经重复的次数: {self.metadata['rept']} \n"
|
||||||
f"下次复习日期时间戳: {self.metadata['next_date']}")
|
f"下次间隔: {self.metadata['interval']} 天 \n"
|
||||||
|
f"下次复习日期时间戳: {self.metadata['next_date']}"
|
||||||
|
)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if self.content == other.content:
|
if self.content == other.content:
|
||||||
@@ -94,7 +99,7 @@ class Electron():
|
|||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self.content)
|
return hash(self.content)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if key == "content":
|
if key == "content":
|
||||||
return self.content
|
return self.content
|
||||||
@@ -102,14 +107,10 @@ class Electron():
|
|||||||
return self.metadata[key]
|
return self.metadata[key]
|
||||||
else:
|
else:
|
||||||
raise KeyError(f"Key '{key}' not found in metadata.")
|
raise KeyError(f"Key '{key}' not found in metadata.")
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
if key == "content":
|
if key == "content":
|
||||||
raise AttributeError("content 应为只读")
|
raise AttributeError("content 应为只读")
|
||||||
|
|
||||||
# 可以在此处添加更复杂的验证逻辑,例如只允许修改预定义的 metadata 键
|
|
||||||
# 或者根据键进行类型检查等。
|
|
||||||
|
|
||||||
self.metadata[key] = value
|
self.metadata[key] = value
|
||||||
self.metadata['last_modify'] = time.time()
|
self.metadata['last_modify'] = time.time()
|
||||||
|
|
||||||
@@ -118,14 +119,15 @@ class Electron():
|
|||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.metadata)
|
return len(self.metadata)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def placeholder():
|
def placeholder():
|
||||||
return Electron("电子对象样例内容", {})
|
return Electron("电子对象样例内容", {})
|
||||||
|
|
||||||
|
|
||||||
class Nucleon:
|
class Nucleon:
|
||||||
"""核子: 材料元数据"""
|
"""核子: 材料元数据"""
|
||||||
|
|
||||||
def __init__(self, content: str, data: dict):
|
def __init__(self, content: str, data: dict):
|
||||||
self.metadata = data
|
self.metadata = data
|
||||||
self.content = content
|
self.content = content
|
||||||
@@ -151,7 +153,8 @@ class Nucleon:
|
|||||||
def placeholder():
|
def placeholder():
|
||||||
return Nucleon("核子对象样例内容", {})
|
return Nucleon("核子对象样例内容", {})
|
||||||
|
|
||||||
class NucleonUnion():
|
|
||||||
|
class NucleonUnion:
|
||||||
"""
|
"""
|
||||||
替代原有 NucleonFile 类, 支持复杂逻辑
|
替代原有 NucleonFile 类, 支持复杂逻辑
|
||||||
|
|
||||||
@@ -166,6 +169,7 @@ class NucleonUnion():
|
|||||||
Parameters:
|
Parameters:
|
||||||
path (Path): 包含核子数据的文件路径。
|
path (Path): 包含核子数据的文件路径。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.name = path.name.replace(path.suffix, "")
|
self.name = path.name.replace(path.suffix, "")
|
||||||
@@ -189,8 +193,10 @@ class NucleonUnion():
|
|||||||
tmp = {i.content: i.metadata for i in self.nucleons}
|
tmp = {i.content: i.metadata for i in self.nucleons}
|
||||||
toml.dump(tmp, f)
|
toml.dump(tmp, f)
|
||||||
|
|
||||||
class ElectronUnion():
|
|
||||||
"取代原有 ElectronFile 类, 以支持复杂逻辑"
|
class ElectronUnion:
|
||||||
|
"""取代原有 ElectronFile 类, 以支持复杂逻辑"""
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.name = path.name.replace(path.suffix, "")
|
self.name = path.name.replace(path.suffix, "")
|
||||||
@@ -201,19 +207,21 @@ class ElectronUnion():
|
|||||||
lst.append(Electron(i, all[i]))
|
lst.append(Electron(i, all[i]))
|
||||||
self.electrons = lst
|
self.electrons = lst
|
||||||
self.electrons_dict = {i.content: i for i in lst}
|
self.electrons_dict = {i.content: i for i in lst}
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
"""同步 electrons_dict 中新增对到 electrons 中"""
|
"""同步 electrons_dict 中新增对到 electrons 中"""
|
||||||
self.electrons = self.electrons_dict.values()
|
self.electrons = self.electrons_dict.values()
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
#print(1)
|
# print(1)
|
||||||
with open(self.path, 'w') as f:
|
with open(self.path, 'w') as f:
|
||||||
tmp = {i.content: i.metadata for i in self.electrons}
|
tmp = {i.content: i.metadata for i in self.electrons}
|
||||||
#print(tmp)
|
# print(tmp)
|
||||||
toml.dump(tmp, f)
|
toml.dump(tmp, f)
|
||||||
|
|
||||||
"""class AtomicFile():
|
|
||||||
|
"""
|
||||||
|
class AtomicFile():
|
||||||
def __init__(self, path, type_="unknown"):
|
def __init__(self, path, type_="unknown"):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.type_ = type_
|
self.type_ = type_
|
||||||
@@ -237,10 +245,42 @@ class ElectronUnion():
|
|||||||
return ""
|
return ""
|
||||||
def get_len(self):
|
def get_len(self):
|
||||||
return len(self.datalist)
|
return len(self.datalist)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Atom():
|
|
||||||
|
class Atom:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def placeholder():
|
def placeholder():
|
||||||
return (Electron.placeholder(), Nucleon.placeholder())
|
return (Electron.placeholder(), Nucleon.placeholder(), {})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def advanced_placeholder():
|
||||||
|
return (
|
||||||
|
Electron("两只黄鹤鸣翠柳", {}),
|
||||||
|
Nucleon(
|
||||||
|
"两只黄鹤鸣翠柳",
|
||||||
|
{
|
||||||
|
"note": [],
|
||||||
|
"translation": "臣子李密陈言:我因命运不好,小时候遭遇到了不幸",
|
||||||
|
"keyword_note": {
|
||||||
|
"险衅": "凶险祸患(这里指命运不好)",
|
||||||
|
"夙": "早时,这里指年幼的时候",
|
||||||
|
"闵": "通'悯',指可忧患的事",
|
||||||
|
"凶": "不幸,指丧父"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
{
|
||||||
|
"keydata": {
|
||||||
|
"note": "笔记",
|
||||||
|
"keyword_note": "关键词翻译",
|
||||||
|
"translation": "语句翻译"
|
||||||
|
},
|
||||||
|
"testdata": {
|
||||||
|
"additional_inf": ["translation", "note", "keyword_note"],
|
||||||
|
"fill_blank_test": ["translation"],
|
||||||
|
"draw_card_test": ["keyword_note"]
|
||||||
|
},
|
||||||
|
"is_new_activation": 0
|
||||||
|
}
|
||||||
|
)
|
@@ -1,5 +0,0 @@
|
|||||||
"""Android Termux 无法编译 playsound 库的替代方案,
|
|
||||||
需要安装 playaudio, 并重命名此文件至 playsound.py"""
|
|
||||||
import os
|
|
||||||
def playsound(path):
|
|
||||||
os.system(f"play-audio '{path}'")
|
|
@@ -0,0 +1,52 @@
|
|||||||
|
# 音频预缓存实用程序, 独立于主程序之外, 但依赖 particles 组件
|
||||||
|
import particles as pt
|
||||||
|
import edge_tts as tts
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
def precache(text: str):
|
||||||
|
"""预缓存单个文本的音频"""
|
||||||
|
cache_dir = Path("./cache/voice/")
|
||||||
|
cache_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
cache = cache_dir / f"{text}.wav"
|
||||||
|
if not cache.exists():
|
||||||
|
communicate = tts.Communicate(text, "zh-CN-YunjianNeural")
|
||||||
|
communicate.save_sync(f"./cache/voice/{text}.wav")
|
||||||
|
|
||||||
|
|
||||||
|
def proc_file(path: Path):
|
||||||
|
"""处理单个文件"""
|
||||||
|
nu = pt.NucleonUnion(path)
|
||||||
|
c = 0
|
||||||
|
for i in nu.nucleons:
|
||||||
|
c += 1
|
||||||
|
print(f"预缓存 [{nu.name}] ({c}/{len(nu)}): {i['content']}")
|
||||||
|
precache(i['content'])
|
||||||
|
|
||||||
|
|
||||||
|
def walk(path_str: str):
|
||||||
|
"""遍历目录处理所有文件"""
|
||||||
|
path = Path(path_str)
|
||||||
|
print(f"正在遍历目录: {path}")
|
||||||
|
|
||||||
|
for item in path.iterdir():
|
||||||
|
if item.is_file() and item.suffix == ".toml":
|
||||||
|
print(f"正预缓存文件: {item.name}")
|
||||||
|
proc_file(item)
|
||||||
|
elif item.is_dir():
|
||||||
|
print(f"进入目录: {item.name}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print("音频预缓存实用程序")
|
||||||
|
print("A: 全部缓存")
|
||||||
|
print("C: 清空缓存")
|
||||||
|
|
||||||
|
choice = input("输入选项 $ ").upper()
|
||||||
|
|
||||||
|
if choice == "A":
|
||||||
|
walk("./nucleon")
|
||||||
|
elif choice == "C":
|
||||||
|
shutil.rmtree("./cache/voice", ignore_errors=True)
|
||||||
|
print("缓存已清空")
|
121
puzzles.py
121
puzzles.py
@@ -0,0 +1,121 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
class Puzzle:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BlankPuzzle(Puzzle):
|
||||||
|
"""填空题谜题生成器
|
||||||
|
|
||||||
|
Args:
|
||||||
|
text: 原始字符串(需要 "/" 分割句子, 末尾应有 "/")
|
||||||
|
min_denominator: 最小概率倒数(如占所有可生成填空数的 1/7 中的 7, 若期望值小于 1, 则取 1)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, text: str, min_denominator: int):
|
||||||
|
self.text = text
|
||||||
|
self.min_denominator = min_denominator
|
||||||
|
self.wording = "填空题 - 尚未刷新谜题"
|
||||||
|
self.answer = ["填空题 - 尚未刷新谜题"]
|
||||||
|
|
||||||
|
def refresh(self): # 刷新谜题
|
||||||
|
placeholder = "___SLASH___"
|
||||||
|
tmp_text = self.text.replace("/", placeholder)
|
||||||
|
words = tmp_text.split(placeholder)
|
||||||
|
if not words:
|
||||||
|
return
|
||||||
|
words = [word for word in words if word]
|
||||||
|
num_blanks = min(max(1, len(words) // self.min_denominator), len(words))
|
||||||
|
indices_to_blank = random.sample(range(len(words)), num_blanks)
|
||||||
|
indices_to_blank.sort()
|
||||||
|
blanked_words = list(words)
|
||||||
|
answer = list()
|
||||||
|
for index in indices_to_blank:
|
||||||
|
blanked_words[index] = "__" * len(words[index])
|
||||||
|
answer.append(words[index])
|
||||||
|
self.answer = answer
|
||||||
|
self.wording = "".join(blanked_words)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.wording}\n{str(self.answer)}"
|
||||||
|
|
||||||
|
|
||||||
|
class SelectionPuzzle(Puzzle):
|
||||||
|
"""选择题谜题生成器
|
||||||
|
|
||||||
|
Args:
|
||||||
|
mapping: 正确选项映射 {问题: 答案}
|
||||||
|
jammer: 干扰项列表
|
||||||
|
max_riddles_num: 最大生成谜题数 (默认2个)
|
||||||
|
prefix: 问题前缀
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
mapping: dict,
|
||||||
|
jammer: list,
|
||||||
|
max_riddles_num: int = 2,
|
||||||
|
prefix: str = ""
|
||||||
|
):
|
||||||
|
self.prefix = prefix
|
||||||
|
self.mapping = mapping
|
||||||
|
self.jammer = list(set(jammer + list(mapping.values())))
|
||||||
|
while len(self.jammer) < 4:
|
||||||
|
self.jammer.append(" ")
|
||||||
|
self.max_riddles_num = max(1, min(max_riddles_num, 5))
|
||||||
|
self.wording = "选择题 - 尚未刷新谜题"
|
||||||
|
self.answer = ["选择题 - 尚未刷新谜题"]
|
||||||
|
self.options = []
|
||||||
|
|
||||||
|
def refresh(self):
|
||||||
|
"""刷新谜题,根据题目数量生成适当数量的谜题"""
|
||||||
|
if not self.mapping:
|
||||||
|
self.wording = "无可用题目"
|
||||||
|
self.answer = ["无答案"]
|
||||||
|
self.options = []
|
||||||
|
return
|
||||||
|
|
||||||
|
num_questions = min(self.max_riddles_num, len(self.mapping))
|
||||||
|
questions = random.sample(list(self.mapping.items()), num_questions)
|
||||||
|
puzzles = []
|
||||||
|
answers = []
|
||||||
|
all_options = []
|
||||||
|
|
||||||
|
for question, correct_answer in questions:
|
||||||
|
options = [correct_answer]
|
||||||
|
available_jammers = [
|
||||||
|
j for j in self.jammer if j != correct_answer
|
||||||
|
]
|
||||||
|
if len(available_jammers) >= 3:
|
||||||
|
selected_jammers = random.sample(available_jammers, 3)
|
||||||
|
else:
|
||||||
|
selected_jammers = random.choices(available_jammers, k=3)
|
||||||
|
options.extend(selected_jammers)
|
||||||
|
random.shuffle(options)
|
||||||
|
puzzles.append(question)
|
||||||
|
answers.append(correct_answer)
|
||||||
|
all_options.append(options)
|
||||||
|
|
||||||
|
question_texts = []
|
||||||
|
for i, puzzle in enumerate(puzzles):
|
||||||
|
question_texts.append(f"{self.prefix}:\n {i+1}. {puzzle}")
|
||||||
|
|
||||||
|
self.wording = question_texts
|
||||||
|
self.answer = answers
|
||||||
|
self.options = all_options
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.wording}\n正确答案: {', '.join(self.answer)}"
|
||||||
|
|
||||||
|
|
||||||
|
puz = SelectionPuzzle(
|
||||||
|
{"1+1": "2", "1+2": "3", "1+3": "4"},
|
||||||
|
["2", "5", "0"],
|
||||||
|
3,
|
||||||
|
'求值: '
|
||||||
|
)
|
||||||
|
puz.refresh()
|
||||||
|
print(puz.wording)
|
||||||
|
print(puz.answer)
|
||||||
|
print(puz.options)
|
62
reactor.py
62
reactor.py
@@ -2,12 +2,35 @@ import typing
|
|||||||
import particles as pt
|
import particles as pt
|
||||||
import pathlib
|
import pathlib
|
||||||
import auxiliary as aux
|
import auxiliary as aux
|
||||||
class Parser():
|
import compositions as comps
|
||||||
"""轻量级版本文件解析器, 用于文件管理器的记忆状态解析"""
|
import random
|
||||||
|
#from pprint import pprint as print # debug
|
||||||
|
class Apparatus():
|
||||||
|
"""反应器对象, 决策一个原子的不同记忆方式, 并反馈到布局"""
|
||||||
|
def __init__(self, screen, reactor, atom):
|
||||||
|
self.electron: pt.Electron = atom[0]
|
||||||
|
self.nucleon: pt.Nucleon = atom[1]
|
||||||
|
self.positron: dict = atom[2]
|
||||||
|
self.testdata = self.positron["testdata"]
|
||||||
|
self.procession: typing.List[comps.Composition] = list()
|
||||||
|
if self.positron["is_new_activation"] == 1:
|
||||||
|
self.positron["is_new_activation"] = 0
|
||||||
|
self.procession.append(comps.registry["recognition"](screen, reactor, atom))
|
||||||
|
return
|
||||||
|
for i in self.positron["testdata"].keys():
|
||||||
|
if i == "additional_inf":
|
||||||
|
continue
|
||||||
|
self.procession.append(comps.registry[i](screen, reactor, atom))
|
||||||
|
# self.procession.reverse()
|
||||||
|
random.shuffle(self.procession)
|
||||||
|
|
||||||
|
def iterator(self):
|
||||||
|
yield from self.procession
|
||||||
|
|
||||||
|
|
||||||
class Reactor():
|
class Reactor():
|
||||||
"""反应堆对象, 用于全面解析文件, 并处理和分配一次文件记忆流程的资源与策略"""
|
"""反应堆对象, 处理和分配一次文件记忆流程的资源与策略"""
|
||||||
def __init__(self, nucleon_file: pt.NucleonUnion, electron_file: pt.ElectronUnion, tasked_num):
|
def __init__(self, nucleon_file: pt.NucleonUnion, electron_file: pt.ElectronUnion, screen, tasked_num):
|
||||||
# 导入原子对象
|
# 导入原子对象
|
||||||
self.reported = set()
|
self.reported = set()
|
||||||
self.nucleon_file = nucleon_file
|
self.nucleon_file = nucleon_file
|
||||||
@@ -16,28 +39,30 @@ class Reactor():
|
|||||||
self.atoms_new = list()
|
self.atoms_new = list()
|
||||||
self.atoms_review = list()
|
self.atoms_review = list()
|
||||||
counter = self.tasked_num
|
counter = self.tasked_num
|
||||||
|
self.screen = screen
|
||||||
self.electron_dict = electron_file.electrons_dict
|
self.electron_dict = electron_file.electrons_dict
|
||||||
|
|
||||||
def electron_dict_get_fallback(key) -> pt.Electron:
|
def electron_dict_get_fallback(key) -> pt.Electron:
|
||||||
value = self.electron_dict.get(key)
|
value = self.electron_dict.get(key)
|
||||||
|
|
||||||
# 如果值不存在,则设置默认值
|
# 如果值不存在,则设置默认值
|
||||||
if value is None:
|
if value is None:
|
||||||
value = pt.Electron(key, {}) # 获取默认值
|
value = pt.Electron(key, {}) # 获取默认值
|
||||||
self.electron_dict[key] = value # 将默认值存入字典
|
self.electron_dict[key] = value # 将默认值存入字典
|
||||||
electron_file.sync()
|
electron_file.sync()
|
||||||
|
|
||||||
return value # 返回获取的值(可能是默认值)
|
return value # 返回获取的值(可能是默认值)
|
||||||
|
|
||||||
for nucleon in nucleon_file.nucleons:
|
for nucleon in nucleon_file.nucleons:
|
||||||
atom = (electron_dict_get_fallback(nucleon.content), nucleon)
|
# atom = (Electron, Nucleon, Positron) 即 (记忆元数据, 内容元数据, 运行时数据)
|
||||||
|
atom = (electron_dict_get_fallback(nucleon.content), nucleon, {}) # 使用 "Positron" 代称 atom[2]
|
||||||
|
atom[2]["testdata"] = nucleon_file.testdata
|
||||||
|
atom[2]["keydata"] = nucleon_file.keydata
|
||||||
if atom[0]["is_activated"] == 0:
|
if atom[0]["is_activated"] == 0:
|
||||||
if counter > 0:
|
if counter > 0:
|
||||||
|
atom[2]["is_new_activation"] = 1
|
||||||
atom[0]["is_activated"] = 1
|
atom[0]["is_activated"] = 1
|
||||||
self.atoms_new.append(atom)
|
self.atoms_new.append(atom)
|
||||||
counter -= 1
|
counter -= 1
|
||||||
else:
|
else:
|
||||||
|
atom[2]["is_new_activation"] = 0
|
||||||
if int(atom[0]["next_date"]) <= aux.get_daystamp():
|
if int(atom[0]["next_date"]) <= aux.get_daystamp():
|
||||||
atom[0]["last_date"] = aux.get_daystamp()
|
atom[0]["last_date"] = aux.get_daystamp()
|
||||||
self.atoms_review.append(atom)
|
self.atoms_review.append(atom)
|
||||||
@@ -47,9 +72,10 @@ class Reactor():
|
|||||||
self.failed: list
|
self.failed: list
|
||||||
self.round_title: str
|
self.round_title: str
|
||||||
self.reported: set
|
self.reported: set
|
||||||
self.current_atom: typing.Tuple[pt.Electron, pt.Nucleon]
|
self.current_atom: typing.Tuple[pt.Electron, pt.Nucleon, dict]
|
||||||
self.round_set = 0
|
self.round_set = 0
|
||||||
self.current_atom = pt.Atom.placeholder()
|
self.current_atom = pt.Atom.placeholder()
|
||||||
|
#print(self.atoms_new)
|
||||||
|
|
||||||
def set_round(self, title, procession):
|
def set_round(self, title, procession):
|
||||||
self.round_set = 1
|
self.round_set = 1
|
||||||
@@ -64,13 +90,10 @@ class Reactor():
|
|||||||
2: "新记忆模式",
|
2: "新记忆模式",
|
||||||
3: "总复习模式"
|
3: "总复习模式"
|
||||||
}
|
}
|
||||||
print("Atoms New:", self.atoms_new)
|
|
||||||
print("Atoms Review:", self.atoms_review)
|
|
||||||
|
|
||||||
processions = {
|
processions = {
|
||||||
1: self.atoms_review,
|
1: self.atoms_review,
|
||||||
2: self.atoms_new,
|
2: self.atoms_new,
|
||||||
3: list(set(self.atoms_new + self.atoms_review))
|
3: (self.atoms_new + self.atoms_review)
|
||||||
}
|
}
|
||||||
ret = 1
|
ret = 1
|
||||||
if stage == 1 and len(processions[1]) == 0:
|
if stage == 1 and len(processions[1]) == 0:
|
||||||
@@ -80,6 +103,12 @@ class Reactor():
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def forward(self, step = 1):
|
def forward(self, step = 1):
|
||||||
|
"""
|
||||||
|
返回值规则:
|
||||||
|
1: 重定向至 failed
|
||||||
|
-1: 此轮已完成
|
||||||
|
0: 下一个记忆单元
|
||||||
|
"""
|
||||||
if self.index + step >= len(self.procession):
|
if self.index + step >= len(self.procession):
|
||||||
if len(self.failed) > 0:
|
if len(self.failed) > 0:
|
||||||
self.procession = self.failed
|
self.procession = self.failed
|
||||||
@@ -94,6 +123,7 @@ class Reactor():
|
|||||||
return -1 # 此轮已完成
|
return -1 # 此轮已完成
|
||||||
self.index += step
|
self.index += step
|
||||||
self.current_atom = self.procession[self.index]
|
self.current_atom = self.procession[self.index]
|
||||||
|
self.current_appar = Apparatus(self.screen, self, self.current_atom).iterator()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
@@ -102,6 +132,10 @@ class Reactor():
|
|||||||
self.electron_file.save()
|
self.electron_file.save()
|
||||||
|
|
||||||
def report(self, atom, quality):
|
def report(self, atom, quality):
|
||||||
|
"""
|
||||||
|
0: 初次激活/通过
|
||||||
|
1: 不通过
|
||||||
|
"""
|
||||||
if atom in self.atoms_new:
|
if atom in self.atoms_new:
|
||||||
atom[0].revisor(quality, True)
|
atom[0].revisor(quality, True)
|
||||||
return 0
|
return 0
|
||||||
|
8
requirements.txt
Normal file
8
requirements.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aiohttp==3.12.13
|
||||||
|
aiohttp_jinja2==1.6
|
||||||
|
edge_tts==7.0.2
|
||||||
|
Jinja2==3.1.6
|
||||||
|
playsound==1.2.2
|
||||||
|
rich==14.1.0
|
||||||
|
textual==5.0.1
|
||||||
|
toml==0.10.2
|
15
styles.tcss
15
styles.tcss
@@ -1,16 +1,23 @@
|
|||||||
|
|
||||||
Screen {
|
Screen {
|
||||||
align: center middle;
|
align: center bottom;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#main_container {
|
#main_container {
|
||||||
align: center middle;
|
align: center middle;
|
||||||
width: 80%;
|
width: 95%;
|
||||||
height: auto;
|
height: auto;
|
||||||
border: thick $primary-lighten-2;
|
border: thick $primary-lighten-2;
|
||||||
padding: 2;
|
padding: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#vice_container {
|
||||||
|
align: center middle;
|
||||||
|
width: 95%;
|
||||||
|
height: auto;
|
||||||
|
padding: 2;
|
||||||
|
}
|
||||||
|
|
||||||
#sentence {
|
#sentence {
|
||||||
content-align: center middle;
|
content-align: center middle;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -52,4 +59,4 @@ Button {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
align-horizontal: center;
|
align-horizontal: center;
|
||||||
width: 40%;
|
width: 40%;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user