Cloze deletion - #29
Merged
Merged
Conversation
Wrap a word in {{braces}} and the card is asked with that word taken out.
It is a way of writing a card, not a new kind of card: one Leitner box,
one id, one due date, and tags, hints, undo, editing, images and the log
all work on it unchanged.
The answer column is empty, because the answers live inside the question.
That makes a cloze card a whole card on a single field, so card_from_csv
accepts a one-field line when -- and only when -- it holds a real
deletion, and card_to_csv lowers its three-column floor to one for such a
card. Both halves are needed or a deck of bare sentences would be
rewritten as "sentence,," the first time it was opened, which is the same
rule that already keeps a question,answer,tags deck from growing trailing
commas.
The syntax is Anki's, so decks paste across in both directions. The one
place it needed a decision is the hint separator, which collides with the
"::" a C++ deck is made of. Resolved by looking for a hint only after a
"cN::" prefix: {{std::vector}} is one answer, {{c1::std::vector}} is Anki's
reading of answer-plus-hint, and {{c1::std::vector::}} says so explicitly.
A sentence with several holes is asked one hole at a time within a single
presentation and scheduled once, on the worst of the answers. The
alternative -- one prompt per hole, each moving the box -- would promote a
three-blank card three boxes in one sitting. So the review loop now walks
a vector<Ask> per card instead of a single expected answer, which is also
what collapsed the reversed and normal paths into one thing built up
front rather than rediscovered inside the prompt loop.
Two deliberate exclusions. A cloze card is never asked reversed: its
answers are already inside its question, so a reversed session asks it
forwards and logs it as 'n', because that is how it was actually asked.
And --generate-audio skips them, since a recording is of the question and
a cloze question read aloud is the answer read aloud; the `a` key still
works during review, speaking the open blank as the word "blank".
Also here, because they were in the way:
- The in-app help screen (`h`) had no golden coverage at all. The
existing `help` case is `--help`, which is a different screen printed
by different code. Added `menu-help` before touching print_help.
- Six cloze golden cases, covering a single blank, three blanks with a
hint and a grouped repeat, a reversed session over a mixed deck, undo
restoring a part-answered card, per-blank key withholding on a vim
deck, and --generate-audio skipping one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wrap a word in
{{braces}}and the card is asked with that word taken out.It is a way of writing a card, not a new kind of card: one Leitner box, one
id, one due date, and tags, hints, undo, editing, images and the log all work
on it unchanged. New module
src/cloze.*; still zero dependencies.The deck format did not change, but it did gain a floor
The answer column is empty, because the answers live inside the question. That
makes a cloze card a whole card on a single field, so:
card_from_csvaccepts a one-field line when — and only when — it holds areal deletion. Without that test every line of every text file would be a
card, and the rule that keeps a mistyped path from being overwritten depends
on that not happening.
card_to_csvlowers its three-column floor to one for such a card.Both halves are needed, or a deck of bare sentences would be rewritten as
sentence,,the first time it was opened — the same rule that already keeps aquestion,answer,tagsdeck from growing trailing commas. No new column, sonothing about this can put a file-synced deck in conflict between versions.
The one syntax decision
Anki's syntax, so decks paste across in both directions:
{{text}},{{c1::text}},{{c1::text::hint}}, and|alternatives inside a deletion.The hint separator collides with the
::a C++ deck is made of. Resolved bylooking for a hint only after a
cN::prefix:Several holes: one card, one schedule
They are asked one at a time within a single presentation, each finished blank
filled in for the next, with what it earned kept on screen underneath.
The card is then scheduled once, on the worst of the answers. The
alternative — one prompt per hole, each moving the box — would promote a
three-blank card three boxes in one sitting. One review, one log event,
whatever the sentence is made of.
Structurally this is why the review loop now walks a
vector<Ask>per cardinstead of a single expected answer. That also collapsed the reversed and
normal paths into one thing built up front rather than rediscovered inside the
prompt loop, and it is what makes the hint/quit/audio keys withheld per
blank rather than per card.
Two deliberate exclusions
question, so there is nothing to turn round. A reversed session asks such
cards forwards — which is what lets a mixed deck be studied backwards
without splitting it in two — and logs them as
n, because that is how theywere actually asked.
--generate-audioskips them. A recording is of the question, and acloze question read aloud is the answer read aloud; there is also no single
rendering to make, since a sentence with three holes is asked three ways
against a column that holds one file. The
akey still works during review:the open blank is spoken as the word "blank", and the whole sentence is read
once the card is done.
Tests
make checkis now 1,344 unit checks and 58 golden cases (was 1,233 / 50).Clean under gcc and clang with
-Werrorand-fsanitize=address,undefined -fno-sanitize-recover=undefined, under theenv -iclean room, and from afresh clone.
Six new golden cases: a single blank; three blanks with a hint and a grouped
repeat; a reversed session over a mixed deck; undo restoring a part-answered
card; per-blank key withholding on a vim deck whose first blank is
q; and--generate-audioskipping one.A seventh is unrelated and was in the way: the in-app help screen (
h) hadno end-to-end coverage at all — the existing
helpcase is--help, whichis a different screen printed by different code.
menu-helpwas added beforeprint_helpwas touched.Also:
examples/cloze-science.csv(12 cards, round-trips byte for byte), themanage list shows a cloze card as it will be asked rather than as a row of
braces, and adding or editing one stops asking for an answer it would never
use.