An adapter to import your lookups from GoldenDict to Anki. It also exports your learned words to a plain text file managed by Dropbox.
GoldenDict is a customizable dictionary lookup program. Anki is a powerful flashcard program. Both of them are great, but the experience of putting them together is meh :(
As a user of both, I would like to:
- Use GoldenDict to look up a new word.
- Import the new word into Anki automagically.
- Mark the new word as known when learned in Anki.
- Maintain a list of my "known" words for further usage.
- Sync between devices (mbp, ubuntu@thinkpad, iOS, etc.)
Furthermore, it would be great if I can do the above in a program-friendly, automatable way.
Unfortunately, I didn't find an out-of-box solution to meet my needs yet. So I build this on my own :)
When you look up a word in GoldenDict, it runs a script named tosink
with input %GDWORD%
as this word. tosink
is configured in Dictionaries->Sources->Programs
beforehand. It appends this word in sink.txt
, which is a plain text file managed in Dropbox.
ECDICT is a well-maintained open-source En-Zh dictionary. First, We can use mdict-utils to extracts an SQLite database from the mdx file as a cache to speed up the query. Then omv
queries each word in the sink.txt
to get the HTML of paraphrases. Finally, omv
calls apy to add a new Note
to Anki for each word. The Note
uses the word as the front and the HTML-format paraphrase as the back.
omv
calls apy sync
to do so. (Credits to apy)
For a learned word, you can mark it as "suspended" in Anki so that it won't show up in further reviews. omv
calls apy list
to get all suspended words. Then it appends new suspened words to the known.txt
.
- A Unix-like operating system: macOS, Linux, BSD.
Anki
should be installed (compatible with 2.1.42 as of March 2021)GoldenDict
should be installed (compatible with 1.5.0-RC2 as of March 2021)git
should be installedwget
should be installedpyenv
is optional but recommendedPython >=3.8
is required by the anki package
Configure tosink
in "Dictionaries->Sources->Programs" GoldenDict, such as:
/home/everbird/bin/tosink "%GDWORD%"
So far ~
can not be expanded to the user's home yet in GoldenDict. Please use an absolute path here.
You might want create the dictionary to store the sink.txt
, such as:
mkdir -p ~/Dropbox/vocabulary
pyenv virtualenv 3.9.2 ohmyvocabulary-run # optional
pyenv activate ohmyvocabulary-run # optional
git clone https://github.com/everbird/ohmyvocabulary.git
cd ohmyvocabulary
make install
make fetch-and-init-db
cp ohmyvocabularyrc ~/.ohmyvocabularyrc
# Change .ohmyvocabularyrc to set your Anki base, profile, deck, and paths for *.txt, etc.
pyenv deactivate # optional
To apply the styling from ECDICT, you can get the css below:
cat cache/concise-enhanced.css
Copy & paste the css to the Styling of your Card Type.
(Find the Styling editor at Tools->Manage Note Types->Select default "Basic" and click "Cards..."->Styling
)
Close your Anki to avoid the SQLite database lock first. Let's lookup a word in GoldenDict. Ensure the word appears in the sink.txt
.
cat ~/Dropbox/vocabulary/sink.txt
# Output:
# invincible
Run omv
(I use pyenv so I wrap the omv
with virtualenv activate/deactivate as below)
pyenv activate ohmyvocabulary-run; omv; pyenv deactivate
# Output:
# Checking dependencies ...
# mdict-utils 1.0.11
# apy 0.8.0
# ---===[oh-my-vocabulary]===---
# Database was modified.
# Remember to sync!
# Syncing deck ... done!
# Syncing media ... done!
# No new learned update. Skipping ...
# Update learning ...
# done!
Check your Anki and browse your target deck. The new word should be imported with decent paraphrase.
GoldenDict doesn't follow symlink to write but overwrite with a new file instead. That makes it hard to sync via Dropbox.