Spaced Spatial Repetition software with AI-generated sentence variations for language learning
Project description
MorphCards
Spaced Spatial Repetition (SSR) software with AI-generated sentence variations for language learning.
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 parametersScheduler: Manages spaced repetition scheduling using FSRS algorithmOptimizer: Optimizes FSRS parameters based on review historyVocabularyDatabase: Stores cards, reviews, and vocabulary using DuckDBAIService: Abstract interface for AI sentence generationOpenAIService: OpenAI API integrationGeminiService: Google Gemini API integration
🔍 API Reference
Core Classes
Card
id: Unique identifierword: Word to learnsentence: Current sentenceoriginal_sentence: Original sentence when createdstability: FSRS stability parameter (nullable)difficulty: FSRS difficulty parameter (nullable)due_date: Next review datestate: 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 cardget_due_cards(): Get cards ready for reviewget_learned_vocabulary(): Get all learned wordsadd_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
- FSRS - Free Spaced Repetition Scheduler
- DuckDB - In-process analytical database
- OpenAI - AI language models
- Google Gemini - AI language models
📞 Support
- Author: Felipe Campos Penha
- Email: felipe.penha@alumni.usp.br
- GitHub: @felipepenha
- Issues: GitHub Issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file morphcards-0.1.2.tar.gz.
File metadata
- Download URL: morphcards-0.1.2.tar.gz
- Upload date:
- Size: 39.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b358242a387e058223408a5819c45760a58ddc1718580c69facb5c5fe28af4e7
|
|
| MD5 |
cdd511629a7483f2494dd29ec858212b
|
|
| BLAKE2b-256 |
1097cbb1fab0f3a99c915d8e5bd9d6daafa7e4c12ab7025e40576056c46d3e83
|
Provenance
The following attestation bundles were made for morphcards-0.1.2.tar.gz:
Publisher:
publish-to-pypi.yml on felipepenha/morphcards
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
morphcards-0.1.2.tar.gz -
Subject digest:
b358242a387e058223408a5819c45760a58ddc1718580c69facb5c5fe28af4e7 - Sigstore transparency entry: 451515111
- Sigstore integration time:
-
Permalink:
felipepenha/morphcards@02c9f174440ead8d5d972c23507daf7e33b04e7b -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/felipepenha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@02c9f174440ead8d5d972c23507daf7e33b04e7b -
Trigger Event:
release
-
Statement type:
File details
Details for the file morphcards-0.1.2-py3-none-any.whl.
File metadata
- Download URL: morphcards-0.1.2-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3b193b7e8e2d4d3a9e0f001d0355c5b296d76b68a7baa97f9904584b1b57e86
|
|
| MD5 |
1d53157732ae7568a8b91d545d90edf6
|
|
| BLAKE2b-256 |
286ebc49cd49d941b4b48c29349ced59d48270f20f7d73d70d7309a7f480b242
|
Provenance
The following attestation bundles were made for morphcards-0.1.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on felipepenha/morphcards
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
morphcards-0.1.2-py3-none-any.whl -
Subject digest:
e3b193b7e8e2d4d3a9e0f001d0355c5b296d76b68a7baa97f9904584b1b57e86 - Sigstore transparency entry: 451515127
- Sigstore integration time:
-
Permalink:
felipepenha/morphcards@02c9f174440ead8d5d972c23507daf7e33b04e7b -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/felipepenha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@02c9f174440ead8d5d972c23507daf7e33b04e7b -
Trigger Event:
release
-
Statement type: