Skip to main content

MorphCards

Spaced Spatial Repetition (SSR) software with AI-generated sentence variations for language learning.

Python 3.8+ License: MIT PyPI version

For developer documentation (including containerization and contributing), see DEVELOPERS.md.

🎯 Overview

Traditional SSR software often repeats the exact same sentence cards, leading users to memorize the front of cards rather than truly learning the language. MorphCards solves this by generating new, contextually appropriate sentences each time a card is reviewed, ensuring learners can identify and understand words in different contexts.

✨ Features

  • FSRS-based Spaced Repetition: Uses the Free Spaced Repetition Scheduler for optimal learning intervals
  • AI-Generated Sentence Variations: Creates new sentences using OpenAI or Google Gemini APIs
  • Vocabulary-Aware Generation: Ensures new sentences only use previously learned vocabulary
  • In-Memory Database: Fast DuckDB-based storage for cards and review history
  • Parameter Optimization: Automatically optimizes FSRS parameters based on your learning patterns
  • Multiple AI Services: Support for both OpenAI and Google Gemini APIs
  • CLI Interface: Command-line tool for daily use
  • Web Demo: Interactive Gradio interface for testing and demonstration

🚀 Quick Start

Installation

# Install from PyPI
pip install morphcards

# Install with demo dependencies
pip install morphcards[demo]

Basic Usage

from morphcards import Card, Scheduler, VocabularyDatabase
from morphcards.ai import AIServiceFactory
from datetime import datetime

# Initialize components
db = VocabularyDatabase()
scheduler = Scheduler()
ai_service = AIServiceFactory.create_service("gemini", model_name="gemini-2.5-flash") # Example with model_name

# Create a card
card = Card(
    id="hello_1",
    word="hello",
    sentence="Hello, how are you?",
    original_sentence="Hello, how are you?",
    due_date=datetime.now()
)

# Add to database
db.add_card(card)

# Review the card
updated_card, review_log = scheduler.review_card(
    card=card,
    rating=3,  # Good
    now=datetime.now(),
    ai_api_key="your-api-key",
    vocabulary_database=db,
    ai_service=ai_service
)

print(f"New sentence: {updated_card.sentence}")

Command Line Interface

# Add a new card
morphcards add "bonjour" "Bonjour, comment allez-vous?" --language French

# Review due cards (uses .env file)
morphcards review --ai-service gemini --model-name gemini-2.5-flash

# Show statistics
morphcards stats

# Optimize parameters
morphcards optimize

📊 Demo Interface

Start the interactive demo:

# Run demo locally (after installing with [demo] extras)
morphcards demo

The demo provides:

  • Add Cards: Create new learning cards
  • Review Cards: Interactive review process with AI sentence generation
  • Statistics: View learning progress and vocabulary stats
  • Optimization: Optimize FSRS parameters

🏗️ Architecture

For detailed architecture diagrams and system design, see Architecture Documentation.

Core Components

  • Card: Represents a flashcard with word, sentence, and FSRS parameters
  • Scheduler: Manages spaced repetition scheduling using FSRS algorithm
  • Optimizer: Optimizes FSRS parameters based on review history
  • VocabularyDatabase: Stores cards, reviews, and vocabulary using DuckDB
  • AIService: Abstract interface for AI sentence generation
  • OpenAIService: OpenAI API integration
  • GeminiService: Google Gemini API integration

🔍 API Reference

Core Classes

Card

  • id: Unique identifier
  • word: Word to learn
  • sentence: Current sentence
  • original_sentence: Original sentence when created
  • stability: FSRS stability parameter (nullable)
  • difficulty: FSRS difficulty parameter (nullable)
  • due_date: Next review date
  • state: FSRS state (New, Learning, Review, Relearning)

Scheduler

  • review_card(): Process card review and generate new sentence
  • _fsrs: Internal FSRS scheduler instance (manages parameters internally)

VocabularyDatabase

  • add_card(): Add new card
  • get_due_cards(): Get cards ready for review
  • get_learned_vocabulary(): Get all learned words
  • add_review_log(): Record review completion (now stores UUID for review logs)

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support

Metadata

Release files for morphcards 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for morphcards 0.1.2
File Size Uploaded
morphcards-0.1.2.tar.gz 39.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for morphcards 0.1.2
File Interpreter ABI Platform
morphcards-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 66.2 kB

Release files / morphcards-0.1.2.tar.gz

Download URL morphcards-0.1.2.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b358242a387e058223408a5819c45760a58ddc1718580c69facb5c5fe28af4e7
BLAKE2b-256 checksum
How to use checksums
1097cbb1fab0f3a99c915d8e5bd9d6daafa7e4c12ab7025e40576056c46d3e83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2025.

Transparency log

Release files / morphcards-0.1.2-py3-none-any.whl

Download URL morphcards-0.1.2-py3-none-any.whl
Size 26.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3b193b7e8e2d4d3a9e0f001d0355c5b296d76b68a7baa97f9904584b1b57e86
BLAKE2b-256 checksum
How to use checksums
286ebc49cd49d941b4b48c29349ced59d48270f20f7d73d70d7309a7f480b242
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page