fix: 完善

This commit is contained in:
2025-12-14 23:36:19 +08:00
parent 4f054ed2e5
commit ef5ef6bbca
6 changed files with 28 additions and 16 deletions

View File

@@ -22,12 +22,13 @@ tts_text = "eval:nucleon['content'].replace('/', '')"
# 我们称 "Recognition" 为 recognition 谜题的 alia
"Recognition" = { __origin__ = "recognition", __hint__ = "", primary = "eval:nucleon['content']", secondary = ["eval:nucleon['keyword_note']", "eval:nucleon['note']"], top_dim = ["eval:nucleon['translation']"] }
"SelectMeaning" = { __origin__ = "mcq", __hint__ = "eval:nucleon['content']", primary = "eval:nucleon['content']", mapping = "eval:nucleon['keyword_note']", jammer = "eval:nucleon['keyword_note']", max_riddles_num = "eval:default['mcq']['max_riddles_num']", prefix = "选择正确项: " }
"FillBlank" = { __origin__ = "cloze", __hint__ = "", text = "eval:nucleon['content']", delimiter = "eval:metadata['formation']['delimiter']", min_denominator = "eval:default['cloze']['min_denominator']"}
"FillBlank" = { __origin__ = "mcq", __hint__ = "eval:nucleon['content']", primary = "eval:nucleon['content']", mapping = "eval:nucleon['keyword_note']", jammer = "eval:nucleon['keyword_note']", max_riddles_num = "eval:default['mcq']['max_riddles_num']", prefix = "选择正确项: " }
#"FillBlank" = { __origin__ = "cloze", __hint__ = "", text = "eval:nucleon['content']", delimiter = "eval:metadata['formation']['delimiter']", min_denominator = "eval:default['cloze']['min_denominator']"}
#debug
["__metadata__.orbital.schedule"] # 内置的推荐学习方案
quick_review = [["FillBlank", "1.0"], ["SelectMeaning", "0.5"], ["recognition", "1.0"]]
quick_review = [["FillBlank", "1.0"], ["SelectMeaning", "0.5"], ["Recognition", "1.0"]]
recognition = [["Recognition", "1.0"]]
final_review = [["FillBlank", "0.7"], ["SelectMeaning", "0.7"], ["recognition", "1.0"]]
final_review = [["FillBlank", "0.7"], ["SelectMeaning", "0.7"], ["Recognition", "1.0"]]
["秦孝公据崤函之固, 拥雍州之地,"]
note = []

View File

@@ -51,11 +51,15 @@ class MemScreen(Screen):
def puzzle_widget(self):
try:
#print(self.phaser.state)
# print(self.phaser.state)
print("---debug---")
print(self.procession.cursor)
print(self.procession.current_atom)
self.fission = Fission(self.procession.current_atom, self.phaser.state)
# print(1)
print("---debug---")
puzzle_info = next(self.fission.generate())
#print(puzzle_info)
print(puzzle_info)
return shim.puzzle2widget[puzzle_info["puzzle"]](
atom=self.procession.current_atom, alia=puzzle_info["alia"]
)
@@ -92,7 +96,8 @@ class MemScreen(Screen):
if forwards:
ret = self.procession.forward(1)
if ret == 0:
self.procession = self.phaser.current_procession() # type: ignore
self.procession = self.phaser.current_procession() # type: ignore
print(f"NEWPROC {self.procession.cursor}")
self.load_puzzle()
def action_play_voice(self):

View File

@@ -40,7 +40,7 @@ class SyncScreen(Screen):
def on_button_pressed(self, event: Button.Pressed) -> None:
event.stop()
def action_go_back(self):
self.app.pop_screen()

View File

@@ -3,9 +3,7 @@ from textual.widgets import (
Label,
Button,
)
from textual.containers import (
Container
)
from textual.containers import Container
from textual.widget import Widget
import heurams.kernel.particles as pt
import heurams.kernel.puzzles as pz
@@ -14,6 +12,7 @@ from typing import TypedDict
from bidict import bidict
from heurams.services.hasher import hash
class Setting(TypedDict):
__origin__: str
__hint__: str
@@ -53,12 +52,14 @@ class MCQPuzzle(BasePuzzleWidget):
def _load(self):
cfg = self.atom.registry["orbital"]["puzzles"][self.alia]
self.puzzle = pz.MCQPuzzle(
cfg["mapping"], cfg["jammer"], cfg["max_riddles_num"], cfg["prefix"]
cfg["mapping"], cfg["jammer"], int(cfg["max_riddles_num"]), cfg["prefix"]
)
self.puzzle.refresh()
def compose(self):
setting: Setting = self.atom.registry["nucleon"].metadata["orbital"]["puzzle"][self.alia]
setting: Setting = self.atom.registry["nucleon"].metadata["orbital"]["puzzle"][
self.alia
]
yield Label(setting["primary"], id="sentence")
yield Label(self.puzzle.wording[len(self.inputlist)], id="puzzle")
yield Label(f"当前输入: {self.inputlist}", id="inputpreview")
@@ -93,7 +94,7 @@ class MCQPuzzle(BasePuzzleWidget):
self.inputlist.pop()
self.refresh_buttons()
self.update_display()
elif button_id.startswith("select"): # type: ignore
# 选项选择处理
answer_text = self.hashmap[button_id[7:]] # type: ignore
@@ -104,7 +105,7 @@ class MCQPuzzle(BasePuzzleWidget):
is_correct = self.inputlist == self.puzzle.answer
rating = 4 if is_correct else 2
self.screen.rating = rating # type: ignore
self.screen.rating = rating # type: ignore
# 重置输入(如果回答错误)
if not is_correct:

View File

@@ -9,11 +9,13 @@ class Fission:
def __init__(self, atom: pt.Atom, phase=PhaserState.RECOGNITION):
self.atom = atom
#print(f"{phase.value}")
self.orbital_schedule = atom.registry["orbital"]["schedule"][phase.value] # type: ignore
self.orbital_puzzles = atom.registry["orbital"]["puzzles"]
# print(self.orbital_schedule)
self.puzzles = list()
for item, possibility in self.orbital_schedule: # type: ignore
print(f"ad:{item}")
if not isinstance(possibility, float):
possibility = float(possibility)
while possibility > 1:
@@ -31,6 +33,8 @@ class Fission:
"alia": item,
}
)
print(f"ok:{item}")
def generate(self):
yield from self.puzzles

View File

@@ -21,10 +21,11 @@ class Procession:
else:
self.state = ProcessionState.RUNNING
try:
print(self.cursor)
self.current_atom = self.queue[self.cursor]
return 1 # 成功
except IndexError as e:
print(f"{e}")
#print(f"{e}")
self.state = ProcessionState.FINISHED
return 0