Skip to content

Instantly share code, notes, and snippets.

@L-M-Sherlock
L-M-Sherlock / anki_recalc_freqsort.md
Created February 19, 2026 08:10
Recalculate harmonic frequency rank for Anki (Lapis)

anki_recalc_freqsort.py Usage

What It Does

Recalculates a harmonic frequency rank from a HTML frequency list and writes the result to a target field.

Computation rules (Yomitan-aligned):

  • Deduplicate by dictionary: only the first occurrence per dictionary is used.
  • Parse numeric prefix from the value (e.g. 12345㋕ -> 12345).
  • Harmonic mean with floor: floor(n / sum(1/f)).
  • If no valid values, write 9999999.
@L-M-Sherlock
L-M-Sherlock / getCardRevlog.py
Created October 3, 2022 13:17
get Anki's entire review history of a card
from anki.collection import Collection
col = Collection("path/to/collection.anki2")
print(col.card_stats_data(card_id).revlog)
@L-M-Sherlock
L-M-Sherlock / getCardStateCustomizer.py
Created October 3, 2022 13:15
get Anki's custom scheduling code
from anki.collection import Collection
col = Collection("path/to/collection.anki2")
print(col.all_config()['cardStateCustomizer'])