Liking cljdoc? Tell your friends :D

clj-anki.core

The core library for interacting with Anki files. The two main functions of interest are 'read-notes' and 'map-seq-to-package!'

The core library for interacting with Anki files. The two main
functions of interest are 'read-notes' and 'map-seq-to-package!'
raw docstring

database-specclj

The a map to use as the base for database connections.

Set up according to the data source information here: http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html

The a map to use as the base for database connections.

Set up according to the data source information here:
http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html
sourceraw docstring

map-seq-to-collection!clj

(map-seq-to-collection! inmaps outfile)

Given a sequence of maps with :answers, :tags, and :question entries, this function will create a new Anki collection at the path specified by the outfile.

For each map in the collection:

  • :question is a String, and will be shown on the front of the card
  • :answers is a collection of Strings representing the fields on the back of the card
  • :tags are an optional collection of Strings that will be set as tags. Tags cannot have spaces in them.

Altogether the first argument for this function should look something like:

[{:question "Nice weather we're having!" :answers ["Y-you too..."]} {:question "What's up?" :answers ["I'm good"]} {:question "This one or that one?" :answers ["Yes"]}]

...give or take some people skills, of course.

Given a sequence of maps with :answers, :tags, and :question
entries, this function will create a new Anki collection at the path
specified by the outfile.

For each map in the collection:
- :question is a String, and will be shown on the front of the card
- :answers is a collection of Strings representing the fields on the
  back of the card
- :tags are an optional collection of Strings that will be set as
  tags. Tags cannot have spaces in them.

Altogether the first argument for this function should look
something like:

[{:question "Nice weather we're having!" :answers ["Y-you too..."]}
 {:question "What's up?" :answers ["I'm good"]}
 {:question "This one or that one?" :answers ["Yes"]}]

...give or take some people skills, of course.
sourceraw docstring

map-seq-to-package!clj

(map-seq-to-package! inmaps outfile)

Like 'map-seq-to-collection!', except the resulting outfile is a full-blown Anki package that can be imported into Anki directly.

Given a collection of maps with :answers, :tags, and :question entries, this function will create a new Anki package at the path specified by the outfile.

For each map in the collection:

  • :question is the String that will be shown on the front of the card in the resulting package.
  • :answers is a collection of Strings representing the fields on the back of the card.
  • :tags is an optional collection of Strings that will be set as tags. Tags cannot have spaces in them.

The first argument to this function should look something similar to:

[{:question "Are you going to do more useless basic math examples?" :answers ["Probably"] :tags #{"FAQ"}} {:question "Why are you writing different examples for the same structure?" :answers ["Because different examples make things easier to remember!"] :tags #{"FAQ"}} {:question "What does a card with no tags and two answers look like?" :answers ["Like this!" "See?"]}]

Like 'map-seq-to-collection!', except the resulting outfile is a
full-blown Anki package that can be imported into Anki directly.

Given a collection of maps with :answers, :tags, and :question
entries, this function will create a new Anki package at the path
specified by the outfile.

For each map in the collection:

- :question is the String that will be shown on the front of the
  card in the resulting package.
- :answers is a collection of Strings representing the fields on the
  back of the card.
- :tags is an optional collection of Strings that will be set as
  tags. Tags cannot have spaces in them.

The first argument to this function should look something similar to:

[{:question "Are you going to do more useless basic math examples?"
  :answers ["Probably"]
  :tags #{"FAQ"}}
 {:question "Why are you writing different examples for the same structure?"
  :answers ["Because different examples make things easier to remember!"]
  :tags #{"FAQ"}}
{:question "What does a card with no tags and two answers look like?"
 :answers ["Like this!" "See?"]}]
sourceraw docstring

normalize-notecljmultimethod

Normalizes a conformed note-type into a map that can be used by map-seq-to-collection!

Normalizes a conformed note-type into a map that can be used by
`map-seq-to-collection!`
sourceraw docstring

normalize-notesclj

(normalize-notes & notes)

Normalizes a set of notes from the user in any form into keyed-notes to be used by other functions.

Normalizes a set of notes from the user in any form into
keyed-notes to be used by other functions.
sourceraw docstring

notes-to-collection!clj

(notes-to-collection! notes outfile)

Given a list of notes and a file path, makes an Anki collection (database) at outfile

Notes can be in a number of styles. For example:

  • Pairs: ([<question> <answer> <question> <answer> ...])

(let [notes ["What's new Scooby Doo?" "<silence>" "Where are you?" "<more silence>"]] (notes-to-collection! notes "scooby.anki2"))

  • Lists: ([[<question> <answer> <answer> <answer> ...] [<question> ...]])

    (let [notes [["What's new Scooby Doo?" "<silence>" "Zoinks!"] ["Where are you?" "<more silence>" "Ruh-roh!"]]] (notes-to-collection! notes "scooby.anki2"))

  • Maps: ([{:question <question> :answer <answer> :tags #{<tag> <tag>}} ...])

    (let [notes [{:question "What's new Scooby Doo?" :answer "<silence>" :tags #{"Scooby"}}

             {:question "Where are you?"
              :answer "<more silence>"
              :tags #{"Scooby"}}]]
    

    (notes-to-collection! notes "scooby.anki2"))

  • Maps with multiple answers: ([{:question <question> :answers [<answer> <answer> ...] :tags #{<tag> <tag>}} ...])

    (let [notes [{:question "What's new Scooby Doo?" :answers ["<silence>" "Zoinks!"] :tags #{"Scooby"}}

             {:question "Where are you?"
              :answers ["<more silence>" "Ruh-roh!"]
              :tags #{"Scooby"}}]]
    

    (notes-to-collection! notes "scooby.anki2"))

  • Also mixes of any of the above work in unison:

    (let [notes ["What's new Scooby Doo?" "<silence>" {:question "Where are you?" :answer "<more silence>" :tags #{"Scooby"}}]] (notes-to-collection! notes "scooby.anki2"))

(See notes-to-package! for more examples.)

Given a list of notes and a file path, makes an Anki
collection (database) at `outfile`

Notes can be in a number of styles. For example:

- Pairs:
([<question> <answer> <question> <answer> ...])

(let [notes ["What's new Scooby Doo?" "<silence>"
             "Where are you?" "<more silence>"]]
  (notes-to-collection! notes "scooby.anki2"))

- Lists:
  ([[<question> <answer> <answer> <answer> ...]
    [<question> ...]])

  (let [notes [["What's new Scooby Doo?" "<silence>" "Zoinks!"]
               ["Where are you?" "<more silence>" "Ruh-roh!"]]]
    (notes-to-collection! notes "scooby.anki2"))

- Maps:
  ([{:question <question>
     :answer <answer>
     :tags #{<tag> <tag>}}
    ...])

  (let [notes [{:question "What's new Scooby Doo?"
                :answer "<silence>"
                :tags #{"Scooby"}}

               {:question "Where are you?"
                :answer "<more silence>"
                :tags #{"Scooby"}}]]
    (notes-to-collection! notes "scooby.anki2"))

- Maps with multiple answers:
  ([{:question <question>
     :answers [<answer> <answer> ...]
     :tags #{<tag> <tag>}}
    ...])

  (let [notes [{:question "What's new Scooby Doo?"
                :answers ["<silence>" "Zoinks!"]
                :tags #{"Scooby"}}

               {:question "Where are you?"
                :answers ["<more silence>" "Ruh-roh!"]
                :tags #{"Scooby"}}]]
    (notes-to-collection! notes "scooby.anki2"))

- Also mixes of any of the above work in unison:

  (let [notes ["What's new Scooby Doo?" "<silence>"
               {:question "Where are you?"
                :answer "<more silence>"
                :tags #{"Scooby"}}]]
    (notes-to-collection! notes "scooby.anki2"))

(See `notes-to-package!` for more examples.)
sourceraw docstring

notes-to-package!clj

(notes-to-package! notes outfile)

Given a list of notes and an outfile (Usually an .apkg), this function creates an Anki package containing all of the notes.

Notes can be in a number of styles. (And mixed!) For example:

(let [cards [{:question "Do you know the muffin man?" :answers ["The muffin man?" "The muffin man!"]}

         "But, do you know the muffin man?" "Yes"

         {:question "However, do you know the muffin man?"
          :answers ["I do" "Stop it"]}

         {:question "Do you kn--"
          :answer "STOP"
          :tags #{"repetition"}}

         {:question "Where is the muffin man?"
          :answer "Maybe Drury Lane..?"}

         "Where?" "I said I think he lives on Drury Lane!"

         ["What are we talking about?" "..." "Ugh"]]]

(notes-to-package! cards "muffin-man.apkg"))

(See notes-to-collection! for more elaborate format examples)

Given a list of `notes` and an `outfile` (Usually an .apkg),
this function creates an Anki package containing all of the notes.

Notes can be in a number of styles. (And mixed!) For example:

(let [cards [{:question "Do you know the muffin man?"
              :answers ["The muffin man?" "The muffin man!"]}

             "But, do you know the muffin man?" "Yes"

             {:question "However, do you know the muffin man?"
              :answers ["I do" "Stop it"]}

             {:question "Do you kn--"
              :answer "STOP"
              :tags #{"repetition"}}

             {:question "Where is the muffin man?"
              :answer "Maybe Drury Lane..?"}

             "Where?" "I said I think he lives on Drury Lane!"

             ["What are we talking about?" "..." "Ugh"]]]
  (notes-to-package! cards "muffin-man.apkg"))

(See `notes-to-collection!` for more elaborate format examples)
sourceraw docstring

read-notesclj

(read-notes anki-package)

Given the path to a .apkg file, reads :answers, :question, and :tags fields and returns them in the same way read-notes-from-collection does, so given a deck with the cards:

| Question | Answers | Tags | |------------------------------+-------------------------+--------------| | Guy who wrote this sentence | Archenoth | people | | Person reading this sentence | (Uh, what's your name?) | people, cool |

You would get back a collection of maps like:

({:question "Guy who wrote this sentence", :answers ("Archenoth"), :tags #{"people"}}

{:question "Person reading this sentence", :answers ("(Uh, what's your name?)"), :tags #{"cool" "people"}})

Given the path to a .apkg file, reads :answers, :question,
  and :tags fields and returns them in the same way
  read-notes-from-collection does, so given a deck with the cards:

| Question                     | Answers                 | Tags         |
|------------------------------+-------------------------+--------------|
| Guy who wrote this sentence  | Archenoth               | people       |
| Person reading this sentence | (Uh, what's your name?) | people, cool |

You would get back a collection of maps like:

({:question "Guy who wrote this sentence",
  :answers ("Archenoth"),
  :tags #{"people"}}

 {:question "Person reading this sentence",
  :answers ("(Uh, what's your name?)"),
  :tags #{"cool" "people"}})
sourceraw docstring

read-notes-from-collectionclj

(read-notes-from-collection anki-collection)

Given the path to a .anki2 file, reads :answers, :question, and :tags entries from its notes and returns them as a list of maps.

If you had a deck with two cards like:

| Question | Answers | Tags | |----------+---------+------| | 2 + 2 | 4, Four | math | | 3 + 3 | 6, Six | math |

You would get back a collection of maps like:

({:question "2 + 2", :answers ["4" "Four"], :tags #{"math"}} {:question "3 + 3", :answers ["6" "Six"], :tags #{"math"}})

Given the path to a .anki2 file, reads :answers, :question,
  and :tags entries from its notes and returns them as a list of maps.

If you had a deck with two cards like:

| Question | Answers | Tags |
|----------+---------+------|
| 2 + 2    | 4, Four | math |
| 3 + 3    | 6, Six  | math |

You would get back a collection of maps like:

({:question "2 + 2", :answers ["4" "Four"], :tags #{"math"}}
 {:question "3 + 3", :answers ["6" "Six"], :tags #{"math"}})
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close