french-wiktionary-flashcards

Easily create Anki flashcards from Wiktionary data.
Log | Files | Refs | README

README.md (4794B)


      1 # README
      2 
      3 This program provides a fast local dictionary, with the option to add any word &
      4 its definition to Anki.
      5 
      6 You'll need a working Go runtime in order to build this program. Usually you can
      7 get this from your distribution's package manager, or from
      8 https://go.dev/doc/install.
      9 
     10 ## Getting started
     11 
     12 You need a copy of
     13 https://kaikki.org/frwiktionary/raw-wiktextract-data.jsonl.gz. Uncompress it to
     14 raw-wiktextract-data.jsonl. This is a structured dump of French wiktionary.
     15 
     16 To be able to add Anki cards, you need to install the `anki-connect` extension.
     17 You can find instructions to do so here: https://git.sr.ht/~foosoft/anki-connect
     18 When you're running this app, you'll also need to have Anki open (with the
     19 `anki-connect` plugin installed) in order to add new cards.
     20 
     21 Also from Anki, take note of the name of the Deck where you want to add new
     22 cards, and the `Type` of these cards (appears in the upper-left of the 'add new
     23 cards' dialog in Anki).
     24 
     25 (Note: currently this application assumes that your card type has two fields:
     26 "Front" and "Back". Eventually, this may be configurable. If the fields are
     27 called something else in your card type, you'll currently have to update the
     28 json tags for the `fields` struct in `add.go`.)
     29 
     30 With all this done, you can now run the app! The first time you run it, the app
     31 will build a SQLite database of words and definitions from the Wiktionary data,
     32 which will take a minute or two. From the root of this repository, you can use a
     33 command like this to start the app:
     34 
     35 ```
     36 go run . -rawDictionary=raw-wiktextract-data.jsonl -deck="Français" -model="Basic-830ae"
     37 ```
     38 
     39 In addition to starting the program and then looking up a word interactively,
     40 it's also possible to provide the first word to look up as a command-line
     41 argument. Then, for example, you could add a shell function to invoke the
     42 program and immediately go to a definition.
     43 
     44 For example, if you've compiled the program and placed it in your path, you
     45 could add a shell function to your `.zshrc` or `.bashrc` with all the arguments
     46 you need, like this:
     47 
     48 ```
     49 wk() {
     50   french-wiktionary-flashcards dictionary=/path/to/dictionary.sqlite3 -deck="Français" -model="Basic-830ae" -initialWord="$*"
     51 }
     52 ```
     53 
     54 and then, to start the program and go immediately to a definition (e.g.
     55 "poisson"), you could invoke it like this:
     56 
     57 ```
     58 $ wk poisson
     59 ```
     60 
     61 ## Usage
     62 
     63 ```
     64 Usage of french-wiktionary-flashcards:
     65   -apiURL string
     66         Base URL to access the anki-connect plugin API. (default
     67         "http://localhost:8765")
     68   -deck string
     69         Name of the deck where new Anki cards will be created.
     70   -dictionary string
     71         Path to the parsed dictionary data. This will be generated
     72         from rawDictionary. (default "dictionary.sqlite3")
     73   -model string
     74         Name of the card type ('model') for new Anki cards.
     75   -initialWord string
     76         Optional: first word to look up on program launch.
     77   -rawDictionary string
     78         Path to the raw wiktionary data. You can get this by
     79         downloading and unzipping
     80         https://kaikki.org/frwiktionary/raw-wiktextract-data.jsonl.gz
     81         (for French). (default "raw-wiktextract-data.jsonl")
     82 ```
     83 
     84 # TODO
     85 
     86 - Include context hints (e.g. see entry for 'panais', which has "Agriculture",
     87   "Par métonomie", etc) in definitions (tricky because the tags are in english
     88   and I would want to display them in the target language).
     89 - suggest closest word when there's no match (help with spelling errors). Not
     90   sure if this is too much complexity for my concept for this application (e.g.
     91   how would the interface work?)
     92 - allow setting the language for initial processing, so that we could support
     93   languages other than French
     94 - italicise part-of-speech in the TUI
     95     - maybe we could create the Anki and the TUI definitions at the same time
     96       during initial parsing? Then we'd have all the information required to do
     97       a really good job of it.
     98 - better gender tags -- jq through the source data to see what's common
     99 - some kind of tests?
    100 
    101 # Ideas for future improvements
    102 
    103 - if the deck and model aren't provided, figure out the defaults and use them
    104 - the first run could download the dictionary database and do all the setup,
    105   with interactive options to choose the language and such.
    106 - provide history (scrollback) of words looked up, to make it easier to switch
    107   between definitions
    108 - definitions for different parts of speech could be more clearly separated in
    109   the preview window. I think it's best to have all the different senses
    110   combined onto one card, but it could still be interesting to allow the user to
    111   scroll between them.
    112 - store data in sqlite with more structure to make it easier to customize
    113   the format of definitions on cards
    114 - figure out some way to customize the names of the fields on the flashcards