Flashcard maker is a simple TypeScript application which reads a PDF file, and then uses Claude to generate Anki-compatible cloze flashcards (as CSV file). Thanks to use of carefully crafted prompting rules, the clozes are placed over the most important fact in the card - at least, most of the time! Meanwhile, it ignores paragraphs discussing historical information, trivia, and similar. These 2 features - smart cloze placement, and omitting irrelevant details - distinguishes the application from existing third-party solutions.
- Clone the project:
git clone https://github.com/antea-p/flashcard_maker.git
- To proceed, you will need npm. If on Windows, see this article: https://phoenixnap.com/kb/install-node-js-npm-on-windows
- Then, install
ts-node
package. If desired, you can install it on global level:
npm install -g ts-node
- Navigate to the project's root directory, open your terminal, and get the rest of the dependencies by executing:
npm install
- Create .env file with following contents:
ANTHROPIC_ACCESS_KEY=YOUR_ANTHROPIC_TOKEN_GOES_HERE
- In index.ts, change the following line:
const filePath = `RELATIVE_OR_ABSOLUTE_PATH_TO_YOUR_PDF`;
- Execute the following command:
npx ts-node index.ts
Note: Keep in mind that each time you execute the script, your old output.csv will be overwritten with fresh data! If you want to avoid this, please change the following line:
console.log(await writeCsv('output.csv', allClozes));
- Open Anki, and select any deck you wish. Then, go to File --> Import..., and select your CSV file. In new dialog, change Field separator to Semicolon. Use of Enhanced Cloze as your Note Type is highly recommended, though optional.