fix: 完善
This commit is contained in:
@@ -22,12 +22,13 @@ tts_text = "eval:nucleon['content'].replace('/', '')"
|
|||||||
# 我们称 "Recognition" 为 recognition 谜题的 alia
|
# 我们称 "Recognition" 为 recognition 谜题的 alia
|
||||||
"Recognition" = { __origin__ = "recognition", __hint__ = "", primary = "eval:nucleon['content']", secondary = ["eval:nucleon['keyword_note']", "eval:nucleon['note']"], top_dim = ["eval:nucleon['translation']"] }
|
"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 = "选择正确项: " }
|
"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"] # 内置的推荐学习方案
|
["__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"]]
|
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 = []
|
note = []
|
||||||
|
|||||||
@@ -51,11 +51,15 @@ class MemScreen(Screen):
|
|||||||
|
|
||||||
def puzzle_widget(self):
|
def puzzle_widget(self):
|
||||||
try:
|
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)
|
self.fission = Fission(self.procession.current_atom, self.phaser.state)
|
||||||
# print(1)
|
# print(1)
|
||||||
|
print("---debug---")
|
||||||
puzzle_info = next(self.fission.generate())
|
puzzle_info = next(self.fission.generate())
|
||||||
#print(puzzle_info)
|
print(puzzle_info)
|
||||||
return shim.puzzle2widget[puzzle_info["puzzle"]](
|
return shim.puzzle2widget[puzzle_info["puzzle"]](
|
||||||
atom=self.procession.current_atom, alia=puzzle_info["alia"]
|
atom=self.procession.current_atom, alia=puzzle_info["alia"]
|
||||||
)
|
)
|
||||||
@@ -92,7 +96,8 @@ class MemScreen(Screen):
|
|||||||
if forwards:
|
if forwards:
|
||||||
ret = self.procession.forward(1)
|
ret = self.procession.forward(1)
|
||||||
if ret == 0:
|
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()
|
self.load_puzzle()
|
||||||
|
|
||||||
def action_play_voice(self):
|
def action_play_voice(self):
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class SyncScreen(Screen):
|
|||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
event.stop()
|
event.stop()
|
||||||
|
|
||||||
def action_go_back(self):
|
def action_go_back(self):
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ from textual.widgets import (
|
|||||||
Label,
|
Label,
|
||||||
Button,
|
Button,
|
||||||
)
|
)
|
||||||
from textual.containers import (
|
from textual.containers import Container
|
||||||
Container
|
|
||||||
)
|
|
||||||
from textual.widget import Widget
|
from textual.widget import Widget
|
||||||
import heurams.kernel.particles as pt
|
import heurams.kernel.particles as pt
|
||||||
import heurams.kernel.puzzles as pz
|
import heurams.kernel.puzzles as pz
|
||||||
@@ -14,6 +12,7 @@ from typing import TypedDict
|
|||||||
from bidict import bidict
|
from bidict import bidict
|
||||||
from heurams.services.hasher import hash
|
from heurams.services.hasher import hash
|
||||||
|
|
||||||
|
|
||||||
class Setting(TypedDict):
|
class Setting(TypedDict):
|
||||||
__origin__: str
|
__origin__: str
|
||||||
__hint__: str
|
__hint__: str
|
||||||
@@ -53,12 +52,14 @@ class MCQPuzzle(BasePuzzleWidget):
|
|||||||
def _load(self):
|
def _load(self):
|
||||||
cfg = self.atom.registry["orbital"]["puzzles"][self.alia]
|
cfg = self.atom.registry["orbital"]["puzzles"][self.alia]
|
||||||
self.puzzle = pz.MCQPuzzle(
|
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()
|
self.puzzle.refresh()
|
||||||
|
|
||||||
def compose(self):
|
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(setting["primary"], id="sentence")
|
||||||
yield Label(self.puzzle.wording[len(self.inputlist)], id="puzzle")
|
yield Label(self.puzzle.wording[len(self.inputlist)], id="puzzle")
|
||||||
yield Label(f"当前输入: {self.inputlist}", id="inputpreview")
|
yield Label(f"当前输入: {self.inputlist}", id="inputpreview")
|
||||||
@@ -93,7 +94,7 @@ class MCQPuzzle(BasePuzzleWidget):
|
|||||||
self.inputlist.pop()
|
self.inputlist.pop()
|
||||||
self.refresh_buttons()
|
self.refresh_buttons()
|
||||||
self.update_display()
|
self.update_display()
|
||||||
|
|
||||||
elif button_id.startswith("select"): # type: ignore
|
elif button_id.startswith("select"): # type: ignore
|
||||||
# 选项选择处理
|
# 选项选择处理
|
||||||
answer_text = self.hashmap[button_id[7:]] # 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
|
is_correct = self.inputlist == self.puzzle.answer
|
||||||
rating = 4 if is_correct else 2
|
rating = 4 if is_correct else 2
|
||||||
|
|
||||||
self.screen.rating = rating # type: ignore
|
self.screen.rating = rating # type: ignore
|
||||||
|
|
||||||
# 重置输入(如果回答错误)
|
# 重置输入(如果回答错误)
|
||||||
if not is_correct:
|
if not is_correct:
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ class Fission:
|
|||||||
|
|
||||||
def __init__(self, atom: pt.Atom, phase=PhaserState.RECOGNITION):
|
def __init__(self, atom: pt.Atom, phase=PhaserState.RECOGNITION):
|
||||||
self.atom = atom
|
self.atom = atom
|
||||||
|
#print(f"{phase.value}")
|
||||||
self.orbital_schedule = atom.registry["orbital"]["schedule"][phase.value] # type: ignore
|
self.orbital_schedule = atom.registry["orbital"]["schedule"][phase.value] # type: ignore
|
||||||
self.orbital_puzzles = atom.registry["orbital"]["puzzles"]
|
self.orbital_puzzles = atom.registry["orbital"]["puzzles"]
|
||||||
# print(self.orbital_schedule)
|
# print(self.orbital_schedule)
|
||||||
self.puzzles = list()
|
self.puzzles = list()
|
||||||
for item, possibility in self.orbital_schedule: # type: ignore
|
for item, possibility in self.orbital_schedule: # type: ignore
|
||||||
|
print(f"ad:{item}")
|
||||||
if not isinstance(possibility, float):
|
if not isinstance(possibility, float):
|
||||||
possibility = float(possibility)
|
possibility = float(possibility)
|
||||||
while possibility > 1:
|
while possibility > 1:
|
||||||
@@ -31,6 +33,8 @@ class Fission:
|
|||||||
"alia": item,
|
"alia": item,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
print(f"ok:{item}")
|
||||||
|
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
yield from self.puzzles
|
yield from self.puzzles
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ class Procession:
|
|||||||
else:
|
else:
|
||||||
self.state = ProcessionState.RUNNING
|
self.state = ProcessionState.RUNNING
|
||||||
try:
|
try:
|
||||||
|
print(self.cursor)
|
||||||
self.current_atom = self.queue[self.cursor]
|
self.current_atom = self.queue[self.cursor]
|
||||||
return 1 # 成功
|
return 1 # 成功
|
||||||
except IndexError as e:
|
except IndexError as e:
|
||||||
print(f"{e}")
|
#print(f"{e}")
|
||||||
self.state = ProcessionState.FINISHED
|
self.state = ProcessionState.FINISHED
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user