# README This program provides a fast local dictionary, with the option to add any word & its definition to Anki. You'll need a working Go runtime in order to build this program. Usually you can get this from your distribution's package manager, or from https://go.dev/doc/install. ## Getting started You need a copy of https://kaikki.org/frwiktionary/raw-wiktextract-data.jsonl.gz. Uncompress it to raw-wiktextract-data.jsonl. This is a structured dump of French wiktionary. To be able to add Anki cards, you need to install the `anki-connect` extension. You can find instructions to do so here: https://git.sr.ht/~foosoft/anki-connect When you're running this app, you'll also need to have Anki open (with the `anki-connect` plugin installed) in order to add new cards. Also from Anki, take note of the name of the Deck where you want to add new cards, and the `Type` of these cards (appears in the upper-left of the 'add new cards' dialog in Anki). (Note: currently this application assumes that your card type has two fields: "Front" and "Back". Eventually, this may be configurable. If the fields are called something else in your card type, you'll currently have to update the json tags for the `fields` struct in `add.go`.) With all this done, you can now run the app! The first time you run it, the app will build a SQLite database of words and definitions from the Wiktionary data, which will take a minute or two. From the root of this repository, you can use a command like this to start the app: ``` go run . -rawDictionary=raw-wiktextract-data.jsonl -deck="Français" -model="Basic-830ae" ``` In addition to starting the program and then looking up a word interactively, it's also possible to provide the first word to look up as a command-line argument. Then, for example, you could add a shell function to invoke the program and immediately go to a definition. For example, if you've compiled the program and placed it in your path, you could add a shell function to your `.zshrc` or `.bashrc` with all the arguments you need, like this: ``` wk() { french-wiktionary-flashcards dictionary=/path/to/dictionary.sqlite3 -deck="Français" -model="Basic-830ae" -initialWord="$*" } ``` and then, to start the program and go immediately to a definition (e.g. "poisson"), you could invoke it like this: ``` $ wk poisson ``` ## Usage ``` Usage of french-wiktionary-flashcards: -apiURL string Base URL to access the anki-connect plugin API. (default "http://localhost:8765") -deck string Name of the deck where new Anki cards will be created. -dictionary string Path to the parsed dictionary data. This will be generated from rawDictionary. (default "dictionary.sqlite3") -model string Name of the card type ('model') for new Anki cards. -initialWord string Optional: first word to look up on program launch. -rawDictionary string Path to the raw wiktionary data. You can get this by downloading and unzipping https://kaikki.org/frwiktionary/raw-wiktextract-data.jsonl.gz (for French). (default "raw-wiktextract-data.jsonl") ``` # TODO - Include context hints (e.g. see entry for 'panais', which has "Agriculture", "Par métonomie", etc) in definitions (tricky because the tags are in english and I would want to display them in the target language). - suggest closest word when there's no match (help with spelling errors). Not sure if this is too much complexity for my concept for this application (e.g. how would the interface work?) - allow setting the language for initial processing, so that we could support languages other than French - italicise part-of-speech in the TUI - maybe we could create the Anki and the TUI definitions at the same time during initial parsing? Then we'd have all the information required to do a really good job of it. - better gender tags -- jq through the source data to see what's common - some kind of tests? # Ideas for future improvements - if the deck and model aren't provided, figure out the defaults and use them - the first run could download the dictionary database and do all the setup, with interactive options to choose the language and such. - provide history (scrollback) of words looked up, to make it easier to switch between definitions - definitions for different parts of speech could be more clearly separated in the preview window. I think it's best to have all the different senses combined onto one card, but it could still be interesting to allow the user to scroll between them. - store data in sqlite with more structure to make it easier to customize the format of definitions on cards - figure out some way to customize the names of the fields on the flashcards