Ankiのleechに集中する

英単語を覚えるためにAnkiを使っているが、デフォルトでは8回間違えるとleechというタグが自動でつけられることになっているっぽい。一度leechがついたら自分でタグを削除しない限りはleechタグが付いたままになっているようだ。

1年ほどAnkiを使っていて気が付いたらleechタグが付いているものが50個以上あったので、leechが付いているカードだけ集中的に取り組むことにした。

単純にAnkiを使ったり単語帳を使うのでは覚えられないような気がしたので、leechが付いている単語を散りばめた文章をChatGPTに作ってもらって、1か月くらい毎日朗読すればどうだろうかと思った。

Ankiは操作方法が独特で特定の単語だけを抜き出してエクスポートするだけでも一工夫必要だった。


大まかな手順

  1. Ankiでleechがついたカードをエクスポート
  2. エクスポートしたファイルから単語だけを抜き出す
  3. ChatGPTに文章を作ってもらう


1.Ankiでleechがついたカードをエクスポート

  1. ツール→フィルターデッキを作成
  2. 作成されたフィルターデッキ→歯車アイコン→エクスポート

leechがついたカードだけ抽出する。Ankiのブラウザのサイドバーの一番下にタグというフィールドがあり、leechというメニューがあるのでクリックする。ここからエクスポートできないかオプションを探したがそういったものは見つからなかった。leechを選択した状態でメニューバーの編集のフィルターデッキを作成を選択すると、leechがついたカードだけを集めたデッキを作成できる。作成すると通常のデッキと同じようにAnkiのデッキリストに表示される。

作成したフィルターデッキの歯車アイコンをクリックするとメニューのエクスポートからエクスポートできる。ここでエクスポートするファイル形式を選べるがテキストファイル形式のノートを選択した。今回の用途ではテキストファイル形式のカードを選択しても大差はないようだ。

エクスポートできたらフィルターデッキは削除した。


2.エクスポートしたファイルから単語だけを抜き出す

エクスポートしたテキストファイルを開くと以下のような感じ。AwesomeTTSというプラグインで表面にmp3をアタッチしているのでこういう形になっている。


stint [sound:azure-b2107c47-162ba92f-20b86ac3-a3db7a12-b87c4a08.mp3] (就労などの)期間
pillage [sound:azure-93be38b2-0d220a49-d21e8db0-0dae3bfb-6af5ff51.mp3] 略奪


スペースで分割すれば単語だけ抽出できる。スペースで分割できれば何でもいいんだけどPythonで。別にutf-8である必要はない。と思う。


input_path = "exportedDeckName.txt"
output_path = "output.txt"

with open(input_path, "r", encoding="utf-8") as infile, open(output_path, "w", encoding="utf-8") as outfile:
for line in infile: first_word = line.split()[0]
outfile.write(first_word + "\n")


3.ChatGPTに文章を作ってもらう

あとはChatGPTに単語を渡す。わざわざ自分で単語だけ抜き出したけど、多分ChatGPTはAnkiからエクスポートしたファイルのままでもやってくれると思う。

In a once congenial town, the people lived in peace, free from tribulation. But their harmony was shattered when an impetuous tyrant usurped the throne, forcing the rightful ruler to abdicate. He was neither lenient nor wise, instead ruling with an odious cruelty that made life unbearable. His conceit was unmatched, and his court was filled with obsequious flatterers who dared not denigrate him.
Under his rule, the town became squalid, its streets littered with filth. The economy corroded, and food supplies were meager, forcing people to scrounge for survival. Those who resisted were met with contempt and brutal punishments, often left emaciated in prison cells. His policies did not conduce to prosperity but rather to suffering, as he continued to pillage the town's resources to fund his vulgar displays of wealth.
Yet, rebellion stirred beneath the surface. A group of ardent revolutionaries, though considered disparate, began working in furtive secrecy. They knew that any misstep could perturb the tyrant, whose blunders were often met with excessive wrath. Even the smallest snag in their plan could mean death.
One night, they saw their opportunity. The tyrant had become imprudent, sending his guards away on a frivolous mission. The rebels, though lacking resources, managed to scrounge together weapons and launched a surprise attack. In the chaos, the palace was plundered, and the despot tried to flee, his fear exasperated by the realization that his power was slipping.
As he ran, he tripped over a slob of a guard who had passed out drunk. This final bug in his escape plan sealed his fate. Cornered, he tried to concede, hoping for mercy. But the people, who had suffered under his scourge for too long, refused to be lenient.
The revolutionaries had to decide: would they execute him or show restraint? A debate ensued, with some arguing for conciliation, while others, still full of scorn, wished to make an example of him. As tensions rose, a forment of anger spread, and violence seemed imminent.
But then, a wise elder stepped forward. “We must not let our rage impervious to reason,” he warned. “Let us not become what we despise.” He proceeded to explicate the need for justice over revenge. Slowly, the people's anger began to abate.
With the tyrant dethroned, the town began to acclimate to its newfound freedom. Though the scars of the past remained, and the streets still bore the marks of war, there was hope. The people had endured, and from their suffering, they had forged a future where no leader could flout their rights again.
The revolution had started in blunder, executed with clumsy tactics, and been threatened by perplexing challenges, but in the end, it had succeeded. The town was free at last.



せっかく出来上がったものの、毎日朗読したくなるような話ではない。

leechはヒルという意味らしい。


2025/02/23追記

せっかくなので上の文章の冒頭をタイピングゲームにしてみた。全文だと長い。肩がこるので冒頭のみ。

typingGame


2025/03/29追記

冒頭だけではなく全文遊べるようタイピングゲームを変更した。500文字前後になるように6個に分けた。

  1. タイピングミスしても修正不要でそのまま進む
  2. 正解は青、不正解はピンクに色が変わる
  3. 正解数を元にWPMを算出
  4. 全文が長い場合適当にスクロールする
  5. ただし自分以外の環境で動作確認していない


2025/05/17追記

タイピングゲームで英単語に触れるをテーマにステージを拡充した。Ankiのleechの単語から作った文章は架空の世界の架空の話だけど、拡充した部分は生き物や植物、生活に関することを題材にした。英検の級ごとにカテゴリーをわけてみたものの実際の英検の各級の出題内容とはかけ離れていると思う。