README.md (5005B)
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 -autosync bool 69 If set to "true", automatically sync the collection to 70 Ankiweb after adding a new card. Useful for running on a 71 a headless server or a machine where Anki is always open. 72 -deck string 73 Name of the deck where new Anki cards will be created. 74 -dictionary string 75 Path to the parsed dictionary data. This will be generated 76 from rawDictionary. (default "dictionary.sqlite3") 77 -model string 78 Name of the card type ('model') for new Anki cards. 79 -initialWord string 80 Optional: first word to look up on program launch. 81 -rawDictionary string 82 Path to the raw wiktionary data. You can get this by 83 downloading and unzipping 84 https://kaikki.org/frwiktionary/raw-wiktextract-data.jsonl.gz 85 (for French). (default "raw-wiktextract-data.jsonl") 86 ``` 87 88 # TODO 89 90 - Include context hints (e.g. see entry for 'panais', which has "Agriculture", 91 "Par métonomie", etc) in definitions (tricky because the tags are in english 92 and I would want to display them in the target language). 93 - suggest closest word when there's no match (help with spelling errors). Not 94 sure if this is too much complexity for my concept for this application (e.g. 95 how would the interface work?) 96 - allow setting the language for initial processing, so that we could support 97 languages other than French 98 - italicise part-of-speech in the TUI 99 - maybe we could create the Anki and the TUI definitions at the same time 100 during initial parsing? Then we'd have all the information required to do 101 a really good job of it. 102 - better gender tags -- jq through the source data to see what's common 103 - some kind of tests? 104 105 # Ideas for future improvements 106 107 - if the deck and model aren't provided, figure out the defaults and use them 108 - the first run could download the dictionary database and do all the setup, 109 with interactive options to choose the language and such. 110 - provide history (scrollback) of words looked up, to make it easier to switch 111 between definitions 112 - definitions for different parts of speech could be more clearly separated in 113 the preview window. I think it's best to have all the different senses 114 combined onto one card, but it could still be interesting to allow the user to 115 scroll between them. 116 - store data in sqlite with more structure to make it easier to customize 117 the format of definitions on cards 118 - figure out some way to customize the names of the fields on the flashcards