Idea for a Batch Python Query with Oxford API

Hi everyone! :wave: I started using Anki a year ago, and at one point I was in need of an add-on that would help me achieve:

  • define a batch of words automatically because I meet more new words than I can spend time creating new cards
  • collect their multiple meanings and attached examples separately
  • collect their pronunciation
  • format the resulting list so as to be compatible with the Anki import feature

Solving the problem

I found several wonderful addons out there doing one or another function, but never all of it. So I spent a couple of days learning the possibilities and came up with a solution within my reach: I wrote a rudimentary python script that does the above mentioned query using a loop and the Oxford API, and prints the result to a file which then I convert to csv and proceed to import into Anki.

All that said, I wanted to publish this script here so perhaps someone could move forward with better implementations of the idea. I’m a mere English philology student, and only know enough programing to get this far.

Check out the repo if you’re interested: https://github.com/Barthcbb/Python-Query-Oxford-API-for-Anki

Background

The necessity behind this script is that the add-ons available, as of the moment of posting this (as deep as I’ve searched anyway), either do not respect the minimum information principle (pulling all meanings and examples at once), or do not respect homonyms.

Most of all, I did it to save time, and even if working on your own cards is the widely recommended practice, I’d prefer to have the card ready to be personalized than not having it.

Possible improvements :bulb:

There are some tweaks that I can only dream of, but that would certainly be amazing. They are:

  • making it an actual add-on
  • pulling from Kindle’s vocab.db
  • pulling other relevant metadata attached to the meaning (such as register ‘formal/informal’, and context ‘medical/historical/scientific’)
  • unifying the script to pull from both the EN-US and EN-GB corpus

As a last remark, I must reinforce that I’m not a programmer and reaching this far was incredibly exhaustive. This is why I’ve decided to throw it out there, so someone better suited could achieve much more.

1 Like

Update

I somehow managed to build a MacOS Shortcut that does the very same—perhaps even better. If you have a Mac M1 and you are running macOS Monterey, you probably can use this.

Check it out: www.icloud.com/shortcuts/8f69cc5d94e84d1aafb0de28011de283
Reddit: https://www.reddit.com/r/shortcuts/comments/srhos6/a_shortcut_to_query_oxford_definitions_examples/

You will still need to get an Oxford Dictionaries API key though.

Update

The beefed up version of the shortcut now collects synonyms, phrasal verbs and phrases for head words. Link: https://www.icloud.com/shortcuts/c35af562600745deacb0a2f07adb4630