dkl9 commited on 2024-13 10:48:34
Showing 3 changed files, with 34 additions and 1 deletions.
Like 44e11a9 or ae90e2a, here's a new `CardType`: each segment (separated by double-semicolon, `;;`) should be used as a prompt from which to recall the following segment, looping to the beginning as needed. Text before the first `;;` is included in each prompt. The "a" option (addcards.lua) accepts `cys` cards, favoured over `seq` but below `bmc`.
| ... | ... |
@@ -40,9 +40,12 @@ local function parsenote(s, ease) |
| 40 | 40 |
return c |
| 41 | 41 |
end |
| 42 | 42 |
c = Card:new({ note = s, ct = "seq", created = os.time() })
|
| 43 |
- for _re in s:gmatch(";;") do
|
|
| 43 |
+ for _re in s:gmatch(";;.") do
|
|
| 44 | 44 |
table.insert(c.pr, Prompt:new({ card = c, ease = ease }))
|
| 45 | 45 |
end |
| 46 |
+ if s:find(";;$") then
|
|
| 47 |
+ c.ct = "cys" |
|
| 48 |
+ end |
|
| 46 | 49 |
if #c.pr >= 1 then |
| 47 | 50 |
return c |
| 48 | 51 |
end |
| ... | ... |
@@ -50,6 +50,27 @@ function Card:fromrecs(recs, conf) |
| 50 | 50 |
ctr = ctr + 1 |
| 51 | 51 |
end |
| 52 | 52 |
table.insert(ret, cc) |
| 53 |
+ elseif cc.ct == "cys" then |
|
| 54 |
+ local m = cc.note:find(";;.")
|
|
| 55 |
+ local ctr = 1 |
|
| 56 |
+ local segs = {}
|
|
| 57 |
+ while m do |
|
| 58 |
+ table.insert(segs, m + 2) |
|
| 59 |
+ m = cc.note:find(";;.", m + 2)
|
|
| 60 |
+ end |
|
| 61 |
+ for i, m in ipairs(segs) do |
|
| 62 |
+ table.insert(cc.pr, Prompt:new({
|
|
| 63 |
+ card = cc, |
|
| 64 |
+ ind = { segs[i == 1 and #segs or i - 1], m },
|
|
| 65 |
+ time = tonumber((rec.LastReview or {})[ctr]),
|
|
| 66 |
+ delay = tonumber((rec.LastDelay or {})[ctr]),
|
|
| 67 |
+ succ = tonumber((rec.Successes or {})[ctr]),
|
|
| 68 |
+ fail = tonumber((rec.Failures or {})[ctr]),
|
|
| 69 |
+ ease = tonumber((rec.Ease or {})[ctr]),
|
|
| 70 |
+ })) |
|
| 71 |
+ ctr = ctr + 1 |
|
| 72 |
+ end |
|
| 73 |
+ table.insert(ret, cc) |
|
| 53 | 74 |
elseif cc.ct == "pwc" then |
| 54 | 75 |
local m = cc.note:find(";;")
|
| 55 | 76 |
local ctr = 1 |
| ... | ... |
@@ -38,6 +38,11 @@ function Prompt:text() |
| 38 | 38 |
if self.card.ct == "bmc" then |
| 39 | 39 |
local _, eoa = self.card.note:find("{[^}]+}", self.ind)
|
| 40 | 40 |
return (self.card.note:sub(1, self.ind - 1) .. "%A" .. self.card.note:sub(eoa + 1)):gsub("{([^}]+)}", "%1")
|
| 41 |
+ elseif self.card.ct == "cys" then |
|
| 42 |
+ local _, ce = self.card.note:find("^.-;;")
|
|
| 43 |
+ local qs = self.ind[1] |
|
| 44 |
+ local qe = (self.card.note:find(";;", qs) or #self.card.note + 1) - 1
|
|
| 45 |
+ return self.card.note:sub(1, ce - 2) .. self.card.note:sub(qs, qe) .. "%A" |
|
| 41 | 46 |
elseif self.card.ct == "pwc" then |
| 42 | 47 |
local _, ce = self.card.note:find("^.-;;")
|
| 43 | 48 |
local qs, as = self.ind[1], self.ind[2] |
| ... | ... |
@@ -57,6 +62,10 @@ function Prompt:ans() |
| 57 | 62 |
end |
| 58 | 63 |
if self.card.ct == "bmc" then |
| 59 | 64 |
return self.card.note:match("{([^}]+)}", self.ind)
|
| 65 |
+ elseif self.card.ct == "cys" then |
|
| 66 |
+ local as = self.ind[2] |
|
| 67 |
+ local ae = (self.card.note:find(";;", as) or #self.card.note + 1) - 1
|
|
| 68 |
+ return self.card.note:sub(as, ae) |
|
| 60 | 69 |
elseif self.card.ct == "pwc" then |
| 61 | 70 |
return self.card.note:match("{([^}]+)}", self.ind[2])
|
| 62 | 71 |
elseif self.card.ct == "seq" then |
| 63 | 72 |