ohare93 / brain-brew

Automated Anki flashcard creation and extraction to/from Csv
The Unlicense
89 stars 5 forks source link

CrowdAnki Subdecks are not Supported Fully #10

Open ohare93 opened 4 years ago

ohare93 commented 4 years ago

CrowdAnki exports can contain a subdeck key in the top level, which is recursive of all the decks below this deck, etc.

Brain Brew does not do anything with this. No idea how difficult this would be to implement.

ohare93 commented 3 years ago

Now supported as read only (Anki -> Source) as of version Cyclops v0.3.4 #24

Support to write to specific subdecks would still be good. Though Refactoring how CrowdAnki does it (rather than the horrible children method) would be better to do first :sweat:

thomasdellaert commented 1 week ago

I've got some interest in trying to tackle this, as I've got ~200 subdecks I'd like to be able to generate separately.

What would something like this look like? For CrowdAnki -> source, perhaps a flag that recursively runs a recipe for each subdeck and puts them in separate folders? Compiling the source back into a crowdanki deck could then be done either recursively through the same folder structure, or for individual subdecks

ohare93 commented 1 week ago

Great to hear! I'll happily review a PR and help out where I can 👍

The main issue here is the question: how do we map the subdecks to a specific source file (csv)?

I implemented "partial support" for subdecks in a crappy way: by simply taking all notes recursively from the CrowdAnki file here. This completely separates the note from the subdeck, and so this should be fixed in order to properly map notes to and from subdecks.

There are many ways I could see full support being implemented:

  1. (Sub)Deck name is a column that sticks with a specific note, and can be placed as a column in the csv.
    • Could also override this for a specific csv, rather than have a column
    • But then I suppose the crowdanki_to_source step should throw a warning if it finds a note in a different subdeck than was expected?
  2. Notes_From_CrowdAnki could make separate DeckParts for each Subdeck, which then get mapped into one csv or many just as is currently done
    • These could be named explicitly or programmatically based on the Subdeck name.
  3. Could set a default subdeck in the source_to_crowdanki recipe, which states where a new card should go into anki
    • All other notes would stay in the subdeck they currently reside in
    • The downside here is that one could not generate a crowdanki export from scratch with the cards in the subdecks, they'd all go in the default
    • The upside is one does not need to care about subdecks in your source files. Just place them in the right place in Anki, and then it will be maintained.
    • Alternatively, all notes can just go in the top level deck, and one can import via CrowdAnki while enabling "Do Not Move Existing Cards" image

So for users backing up their own personal cards and perhaps even updating them programatically, then all should work with Subdecks right now for existing cards 🤔 I believe! But for users that wish to craft a CrowdAnki export with subdecks for others to consume from new, then there is no support for this just now in Brain Brew. That's the main thing that could be good to improve 😁

ohare93 commented 1 week ago

Oh then there's also the possibility of adding a flag to append to an existing CrowdAnki export in a subdeck, rather than overriding any of the parent information (though note models shouldn't be duplicated? 🤔). Then the same for reading from a specific subdeck too.

The difficult thing there would be what about doing it programatically? 😅 for your 200 subdecks, for instance. That would be a large recipe file!