MarvNC / JP-Resources

My contributions to the Japanese learning community.
MIT License
88 stars 4 forks source link

Python backfill #2

Closed Aquafina-water-bottle closed 1 year ago

Aquafina-water-bottle commented 1 year ago

Added a Python script using AnkiConnect in order to backfill the old cards much faster than the current method documented (for me, it ran within 10 seconds when updating 1.7k cards). By default, it takes frequencies in order of "JPDB.txt", "vnsfreq.txt", "vnsfreqSTARS.txt".

Example --help invocation:

$ python3 backfill.py --help
usage: backfill.py [-h] [--freq-field FREQ_FIELD] [--query QUERY] [--freq-lists FREQ_LISTS [FREQ_LISTS ...]]
                   expr_field

positional arguments:
  expr_field            exact field name that contains the expression

optional arguments:
  -h, --help            show this help message and exit
  --freq-field FREQ_FIELD
                        exact field name to fill with the frequency information (default: Frequency)
  --query QUERY         exact note query to send to Anki
  --freq-lists FREQ_LISTS [FREQ_LISTS ...]
                        what lists to use to backfill (default: ['JPDB.txt', 'vnsfreq.txt', 'vnsfreqSTARS.txt'])

Example usage:

$ python3 backfill.py "Word" --freq-field "FrequencySort"
Querying Anki with: 'FrequencySort:'
Query found 1793 notes.
Getting note info...
Parsing frequency lists...
This will change 1746 notes. Type 'yes' to confirm, or anything else to exit.
> yes
Updating notes within Anki...
Done!