sillsdev / flashgrab

An Anki addon for pulling flashcard data (one-way sync) from XML. Optimized for LIFT XML (from WeSay or FLEx). [This is now the official repo. -pconstrictor]
Other
9 stars 4 forks source link

Answered - Is it possible to export an Anki deck to XML so there can be a collaborative data source? #4

Open bzwolf opened 9 years ago

bzwolf commented 9 years ago

ie. a group of people can edit the data and sync changes without updating their review status. There's another addon that creates a unique ID for each note so using that in conjunction with this may help. Any thoughts?

Anki has no good way for people to collaborate on a deck and when I saw this addon I began to wonder if it would make it possible. Thanks.

pconstrictor commented 9 years ago

Yes, this addon is compatible with collaboration--it will pull in changes to the actual XML data without affecting the review status, provided that the field used as the unique 'ID' has not changed. But all the collaboration/merging has to be handled on the source (XML) side. FlashGrab merely pulls the latest data into whatever local Anki deck you tell it to. Again, with any deck you're using FlashGrab on, you should not make any edits in Anki itself that you'd mind losing, as the next one-way sync will overwrite them.

So I'd only recommend going that route if you are highly motivated to do some setup work. For example, you mentioned exporting an existing deck from Anki to XML. You'd then need to migrate that into a tool that (a) supports syncing and that (b) you can set up to work with FlashGrab. (FlashGrab's wizard only has pre-configuration for a specific format named LIFT XML.)

In my context, the source XML is a LIFT file representing a dictionary, and the software products that produce that LIFT XML support some pretty robust syncing using a feature known as "send/receive". (Under the hood they use either a collaborative website or else they use an enhanced Mercurial, for those of you who know how a DVS like Mercurial or Git works. Basically, it allows peers to work offline and sync as they choose.) They also include a convenient Record button, like Anki does.

The LIFT-producing tools I'm referring to are WeSay (http://wesay.palaso.org/), LanguageForge.org, and FLEx (FieldWorks Language Explorer, http://fieldworks.sil.org/). If you go that route, I'd strongly recommend using WeSay or LanguageForge unless you need the more advanced features in FLEx.

At this time, there is no wizard specifically for creating a 'dictionary' intended to represent a flashcard deck, but see the FlashGrab docs for info on which fields to fill in, and where your images and audio should go.

bzwolf commented 9 years ago

Thanks so much for the info. I wonder if the best solution would be to write a python script that pulled the appropriate fields from Anki through sqlite and exported it into an XML file matching your documentation. Being in med school my time to work on this is fairly limited so I'm not sure if I'll be able to pursue this or not.

I see a lot of potential for trying to mimic your multisided cards for my purposes. I plan on checking out the programs you mentioned. It would be incredibly cool and beneficial to be able to create a 'dictionary' of drugs and test by different fields (contraindications, mechanisms, side effects, etc). Could also work for microbiology or even diseases. Thanks for pointing me in the right directions.

pconstrictor commented 9 years ago

I'm not sure I'm fully understanding your reasons for getting the data out of Anki into XML into a format that Anki+FlashGrab can read back in. You did mention collaboration, and that's the one reason that I think you might find that to be worthwhile.

One alternative to pretending it's a dictionary and shoehorning it into WeSay and LIFT would be to create your own XML file as a Google document (so that multiple people can edit it) and pull from there into Anki using FlashGrab. The downside is that you'd have to create your own config file manually--but that's pretty easy if you're the kind of person who can write a Python script.

For example, if this is your file...

<mydoc>
    <myrecord id="abc123">
        <drugname>antigravalin</drugname>
        <brandname>Astronica</brandname>
        <sideeffects>loss of appetite, quick and painless death, boredom, adrenalin imbalance</sideeffects>
        <counterindications>
          <counterindication>alcohol</counterindication>
          <counterindication>skydiving</counterindication>
          <counterindication>joking contests</counterindication>
        </counterindications>
    </myrecord>
    <myrecord> ...
    </myrecord>
    ...
<mydoc>

The xpaths in your config file would look something like this:

<source 
  enabled="true"
  id_field="recordid" base_xpath="//myrecord" anki_deck="medstuff" anki_model="drugrecord"
  ...
  <source_field anki_field="recordid" xpath="@id" grab="first" />
  <source_field anki_field="drugname" xpath="drugname" grab="first"/>
  ...
  <source_field anki_field="counterindications" xpath="counterindications/counterindication" grab="concat_all"/>
  ...    

Note that you don't have to use attributes and the @ notation. If your id is instead like this...

    <myrecord> <id>abc123</id> ...

then your xpath for that field would instead look like this (no @ sign):

  <source_field anki_field="recordid" xpath="id" grab="first" />

-Jon

bzwolf commented 9 years ago

You nailed it- the objective here is the ability to collaborate. Otherwise it does seem like a lot of work for little juice. There's a massive shared deck for the med school board exam USMLE that's posted to ankiweb and several threads on reddit maintaining a list of errata for it. The inability to just maintain a central database makes the process pretty cumbersome which led to me exploring some options to improve the process.

Thanks for the direction with the custom config. that process doesn't seem like it will be too hard. I'm not sure why I thought I'd have to use sqlite, I can probably just convert an Anki-exported csv to xml and write a config for it. Does that sound right? Thanks again, I really appreciate you taking the time to help me figure out a solution.

Ben

pconstrictor commented 9 years ago

Yes, that sounds reasonable to me. And using the xml format that Anki itself exports makes sense. Just remember to stop doing any editing in Anki itself, once the xml file has become the "master copy". And you'll need to make sure that any collaborators who have access to editing the xml know how to do so. (If they 'break' it, you can use an xml-validating website to find where the offending line is--usually a missing slash, angle bracket, or quote.)

P.S. I had a typo in my last message due to copy/paste; it's fixed now.

sgfin commented 9 years ago

Hi,

I apologize if this isn't the appropriate forum, but I am also a first year med student with a CS background and am interested in this exact use case. (I believe you are referring to the Brosencephalon deck?). Feel free to ping me if you decide to keep pursuing this or let me know where to follow your work. samfin55@gmail.com. The key will be to try to make sure it has an interface where students with no coding knowledge are comfortable. And also not to get too distracted from med school :).

Best, Sam

P.S. Someone on the AnkiDroid forum pointed me to this: http://decks.wikia.com/wiki/Ideas, where someone is hoping to also work on this issue.

Stvad commented 8 years ago

Hey @bzwolf @samfin55 I thought you might be interested in looking into the plugin I'm working on right now, that allows you to create full-feature JSON representation of Anki Notes/Decks/etc in order to facilitate collaboration. Some links: The ankiweb page for plugin: https://ankiweb.net/shared/info/1788670778?ok=1 Github: https://github.com/Stvad/CrowdAnki Example of a deck exported via the plugin: https://github.com/Stvad/anki_json_decks Please let me know if you have any feedback or suggestions!