Anki Language Sentence Miner

AnkiWeb addon 267473329

Generates natural Gemini-powered contextual sentences from vocabulary decks, mixing known and new words into cloze and new-word Anki cards.
AI-generated summary; may contain mistakes.

card-creationaicard-templatescloze

Open on AnkiWeb GitHub Ask about alternatives

AnkiWeb

Rating
0 (๐Ÿ‘ 0 ยท ๐Ÿ‘Ž 0)
Updated
2026-02-18
Anki versions
25.09.2~
Description language
en

Maintenance

stale

  • Last update or commit was 225 days before the snapshot (2026-02-18).

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.5525.09.2+2026-02-18
History across monthly snapshots

Loadingโ€ฆ

Similar addons

Vocab Miner

Generates formatted Anki cards from English words using Claude or ChatGPT, with example sentences, IPA, definitions, synonyms, vocabulary breakdowns, Google TTS audio, preview, and duplicate detection.

card-creationaiduplicatesdictionary

Rating 0 ๐Ÿ‘ 0 ยท ๐Ÿ‘Ž 0 โญ 0 Anki 2.1.4~ Updated 2026-03-28
Grammar Trainer

Creates interactive dropdown fill-in-the-blank grammar cards manually or with optional AI assistance, supporting many languages, automatic cloze generation, smart distractors, and text-to-speech.

card-creationaicard-templatesclozequiz

Rating 0 ๐Ÿ‘ 0 ยท ๐Ÿ‘Ž 0 โญ 0 Anki 25.07.1~ Updated 2026-09-26

README

๐Ÿง  Anki Sentence Miner

AI-powered sentence generation for Anki โ€” Turn your vocabulary cards into natural, contextual sentences using Google's Gemini AI.

Sentence Miner bridges the gap between memorizing isolated words and understanding them in real conversation. It reads your vocabulary deck, identifies which words you know well and which you're still learning, then generates sentences that mix them together โ€” just like how you'd encounter them in the real world.


โœจ Features

Two Card Types

Type What It Does Example
๐Ÿ”ฒ Cloze Recall Hides known words so you recall them from context ็ŒซใŒ{{c1::ๅฑ‹ๆ น}}ใฎไธŠใซๅบงใฃใฆใ„ใ‚‹
๐Ÿ†• New Word Introduces unfamiliar words alongside known ones ็ŒซใŒๅฑ‹ๆ นใฎไธŠใซๅบงใฃใฆใ„ใ‚‹

You control the mix with a slider (default: 70% cloze / 30% new word).

Smart Word Selection

The add-on doesn't just randomly pick words. It uses several strategies to create better sentences:

  • Tag-Aware Sampling โ€” If your vocabulary cards are tagged (e.g., food, travel, JLPT_N3), the generator groups words by topic and creates thematically coherent sentences instead of random word combinations.
  • Priority-Weighted New Words โ€” Words you struggle with (high lapse count, low ease factor) or haven't seen yet are prioritized for introduction. This means the sentences focus on words that need the most reinforcement.
  • Confidence Threshold โ€” You define what "known" means by setting a minimum review interval (e.g., 7 days). Cards above that interval are considered known; everything below is a candidate for introduction.

Performance Optimized

  • In-Memory Cache โ€” Word lists are cached for 5 minutes, so hitting "Generate" multiple times doesn't re-query your entire deck each time.
  • Note-Level Deduplication โ€” Fetches each note only once even if it has multiple cards (e.g., forward + reverse cards), preventing duplicate words.
  • Background Generation โ€” API calls run in a background thread so Anki's UI stays responsive.

Natural Sentences

The Gemini prompt is carefully crafted to produce sentences that:

  • Sound like something a native speaker would actually say
  • Fit daily conversation contexts
  • Match the learner's current level
  • Are NOT awkward combinations of random vocabulary

Natural Grammar & Conjugation

  • Context-Aware Conjugation โ€” The AI understands that words in your deck are dictionary forms (lemmas). It automatically conjugates verbs and adjusts nouns/adjectives to fit the sentence context naturally (e.g., changing "go" to "went").
  • Smart Cloze Matching โ€” Even when a word is conjugated, the cloze deletion handles it correctly, hiding the actual used form while preserving the underlying concept.
  • Optional Grammar Breakdown โ€” Can't figure out why a word changed its ending? Enable "Grammar Breakdown" to get a word-by-word analysis of particles, tense, and sentence structure added to your card notes.

๐Ÿ“ฆ Installation

1. Locate Your Add-ons Folder

In Anki, go to Tools โ†’ Add-ons โ†’ View Files Folder (or open the folder manually):

OS Path
Windows %APPDATA%\Anki2\addons21\
macOS ~/Library/Application Support/Anki2/addons21/
Linux ~/.local/share/Anki2/addons21/

2. Copy the Add-on

Copy or symlink the entire anki-sentence-miner folder into addons21/:

addons21/
โ””โ”€โ”€ anki-sentence-miner/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ config.json
    โ”œโ”€โ”€ config.md
    โ”œโ”€โ”€ manifest.json
    โ”œโ”€โ”€ sentence_generator.py
    โ”œโ”€โ”€ note_manager.py
    โ””โ”€โ”€ ui.py

3. Restart Anki

Close and reopen Anki. You should see a new Sentence Miner submenu under Tools.


๐Ÿ”‘ Setting Up Your Gemini API Key (Free)

On first launch, the add-on will prompt you to enter an API key. You can also access this anytime via Tools โ†’ Sentence Miner โ†’ API Key Setup.

  1. Go to Google AI Studio โ€” API Keys
  2. Sign in with your Google account
  3. Click "Create API Key"
  4. Select any Google Cloud project (or create one โ€” it's free, no credit card required)
  5. Copy the key and paste it into the add-on dialog
  6. Click "Test Key" to verify it works
  7. Click "Save"

Free Tier Limits

Model Requests/Min Requests/Day
gemini-2.5-flash 10 250
gemini-2.5-flash-lite 15 1,000

This is more than enough โ€” generating 5 sentences uses 1 request.


๐Ÿš€ Usage

Generating Sentences

  1. Go to Tools โ†’ Sentence Miner โ†’ Generate Sentences
  2. Configure the settings:
Setting What It Controls
Source Deck The vocabulary deck to pull words from
Language I'm Learning Target language (e.g., Japanese, Spanish)
My Native Language Language for translations (e.g., English)
Known Word Threshold Minimum interval (days) for a word to count as "known"
Known Words in Sentence Target percentage of known words per sentence
Card Type Mix Ratio of Cloze cards vs New Word cards
Sentences to Generate How many sentences per batch (1โ€“20)
Sentence Deck Name of the deck where generated cards will go
  1. Click โšก Generate Sentences
  2. Review the generated sentences in the preview table
  3. Uncheck any sentences you don't want
  4. Click โœ… Add Selected to Deck

Settings Are Remembered

All settings are saved automatically and restored next time you open the dialog.


๐Ÿ“‹ Card Structure

AI Sentence (Basic)

Field Content
Sentence The target-language sentence with new words in bold
Translation Natural translation in your native language
NewWords List of new words with readings and definitions
Notes Additional context (if any)

Front shows the sentence with a hint button for new words. Back reveals the translation and word definitions.

AI Sentence Cloze

Field Content
Text The sentence with {{c1::hidden_word}} cloze deletions
Translation Natural translation in your native language
Notes Additional context (if any)

Front shows the sentence with blanks. Back reveals the hidden words and translation.

Both card types include styled templates with:

  • Clean typography (Noto Sans family)
  • Dark mode support
  • Color-coded new words (orange) and cloze words (blue)

โš™๏ธ Configuration

You can edit the config via Tools โ†’ Add-ons โ†’ Sentence Miner โ†’ Config, or directly in config.json:

{
    "gemini_api_key": "",
    "target_language": "",
    "native_language": "",
    "source_deck": "",
    "sentence_deck": "AI Sentences",
    "known_interval_days": 7,
    "known_word_percentage": 70,
    "cloze_percentage": 70,
    "sentences_per_batch": 5,
    "gemini_model": "gemini-flash-latest"
}

See config.md for detailed explanations of each setting.


๐Ÿงฉ How It Works Under the Hood

Word Classification

Your Vocabulary Deck
        โ”‚
        โ”œโ”€โ”€ Cards with interval >= threshold โ”€โ”€โ†’ KNOWN WORDS
        โ”‚     (e.g., interval >= 7 days)         Used for cloze blanks
        โ”‚                                         and sentence scaffolding
        โ”‚
        โ””โ”€โ”€ Cards with interval < threshold โ”€โ”€โ†’ NEW/WEAK WORDS
              (new, learning, or young cards)     Introduced in context
              Sorted by priority:                 with known-word support
              โ€ข High lapses = higher priority
              โ€ข Low ease = higher priority
              โ€ข Brand new = high priority

Smart Sampling Pipeline

All Known Words (e.g., 3,000)
        โ”‚
        โ”œโ”€โ”€ Group by Anki tags
        โ”‚     food: [rice, fish, cook, ...]
        โ”‚     travel: [hotel, ticket, map, ...]
        โ”‚     JLPT_N3: [ๆฑบใ‚ใ‚‹, ๅฑŠใ‘ใ‚‹, ...]
        โ”‚
        โ”œโ”€โ”€ Pick 1-2 focus tag groups
        โ”‚
        โ”œโ”€โ”€ Sample 70% from focus groups โ”€โ”€โ†’ Thematic coherence
        โ””โ”€โ”€ Sample 30% from others โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ Variety
                                                โ”‚
                                        50 words to prompt

All New Words (e.g., 500)
        โ”‚
        โ”œโ”€โ”€ Calculate priority score per word
        โ”‚     score = lapsesร—2 + (3-ease) + new_bonus
        โ”‚
        โ”œโ”€โ”€ Sort by priority (with jitter)
        โ”‚
        โ””โ”€โ”€ Sample from top candidates โ”€โ”€โ†’ 20 words to prompt

Generation Flow

[Smart-sampled words] โ”€โ”€โ†’ [Gemini Prompt] โ”€โ”€โ†’ [API Call]
                                                  โ”‚
                                           [JSON Response]
                                                  โ”‚
                                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                    โ”‚                           โ”‚
                              Cloze Cards               New Word Cards
                           [[word]] โ†’ {{c1::word}}    **word** โ†’ <b>word</b>
                                    โ”‚                           โ”‚
                                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                  โ”‚
                                         [Preview Table]
                                                  โ”‚
                                    [User accepts/rejects]
                                                  โ”‚
                                         [Add to Deck]

๐Ÿ—‚๏ธ Project Structure

anki-sentence-miner/
โ”œโ”€โ”€ __init__.py              # Entry point โ€” menu registration, first-run check
โ”œโ”€โ”€ config.json              # Default settings
โ”œโ”€โ”€ config.md                # User-facing config documentation
โ”œโ”€โ”€ manifest.json            # Anki add-on metadata
โ”œโ”€โ”€ sentence_generator.py    # Word retrieval, smart sampling, Gemini API
โ”œโ”€โ”€ note_manager.py          # Deck/note type creation, card templates
โ”œโ”€โ”€ ui.py                    # PyQt dialogs (API key wizard + generator)
โ””โ”€โ”€ README.md                # This file

๐Ÿค Dependencies

  • Anki 2.1.55+ (uses modern Qt6/PyQt6 APIs)
  • google-genai Python package (auto-installed on first run if missing)
  • A free Gemini API key

๐Ÿ“ License

MIT License โ€” feel free to use, modify, and distribute.