Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Add disclozed content of Cloze into PRNG seed
Browse files Browse the repository at this point in the history
  • Loading branch information
agentydragon committed Apr 13, 2020
1 parent 0ed2926 commit a3ba229
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ TODO: installation instructions
```bash
blaze run //src/deploy -- \
--alsologtostderr \
--collection_path=/home/agentydragon/dropbox/anki/agentydragon/collection.anki2
--collection_path=/home/agentydragon/dropbox/anki/agentydragon/collection.anki2 \
--anki_path=/home/agentydragon/repos/anki/pylib/anki
```
3 changes: 3 additions & 0 deletions src/models/permuted_cloze/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def test_report_error_on_no_container(self):
self.load_front_card(text='Hello World!')
self.assertIn('No permuted container', self.get_log())

# TODO(prvak): Test that front and back permutation for the same card is
# the same.


if __name__ == "__main__":
absltest.main()
1 change: 1 addition & 0 deletions src/shared_styles/common_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<span data-field="Log">{{Log}}</span>
<span data-field="Type">{{Type}}</span>
<span data-field="Card">{{Card}}</span>
<span data-field="TextUnclozed">{{text:Text}}</span>
</div>
<div id="agentydragon-log"></div>
12 changes: 10 additions & 2 deletions src/shared_styles/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ class Note {
* @param {?string} logEnabled
* @param {?string} noteType
* @param {?string} card
* @param {?string} textUnclozed Text field with clozes replaced by their
* exposed content. Used for seeding the PRNG based on card content for
* Permuted Cloze.
*/
constructor(heading, deck, tags, seed, logEnabled, noteType, card) {
constructor(heading, deck, tags, seed, logEnabled, noteType, card,
textUnclozed) {
this.heading_ = heading;
this.deck_ = deck;
this.tags_ = tags;
this.seed_ = seed;
this.logEnabled_ = logEnabled;
this.noteType_ = noteType;
this.card_ = card;
this.textUnclozed_ = textUnclozed;
}

/** @return {?string} */
Expand All @@ -34,6 +39,8 @@ class Note {
get noteType() { return this.noteType_; }
/** @return {?string} */
get card() { return this.card_; }
/** @return {?string} */
get textUnclozed() { return this.textUnclozed_; }
}

/**
Expand All @@ -59,7 +66,8 @@ function obtainNote() {
return value;
};
return new Note(find("Heading"), find("Deck"), find("Tags"), find("Seed"),
find("Log"), find("Type"), find("Card"));
find("Log"), find("Type"), find("Card"),
find("textUnclozed"));
}

exports = {
Expand Down
2 changes: 1 addition & 1 deletion src/shared_styles/rng.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function computeRngSeed(note) {
hash = addHash(hash, today.getDay());
// Add more fields, including specifically dedicated extra seed.
for (const field of [note.heading, note.deck, note.tags, note.seed,
note.noteType, note.card]) {
note.noteType, note.card, note.textUnclozed]) {
hash = addHashString(hash, field);
}
// It would be nice if we could include something about the content of the
Expand Down

0 comments on commit a3ba229

Please sign in to comment.