Spaced Spatial Repetition (SSR) software with AI-generated sentence variations for language learning.
For developer documentation (including containerization and contributing), see DEVELOPERS.md.
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.
- 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
# Install from PyPI
pip install morphcards
# Install with demo dependencies
pip install morphcards[demo]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}")# 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 optimizeStart the interactive demo:
# Run demo locally (after installing with [demo] extras)
morphcards demoThe 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
For detailed architecture diagrams and system design, see Architecture Documentation.
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
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)
review_card(): Process card review and generate new sentence_fsrs: Internal FSRS scheduler instance (manages parameters internally)
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)
This project is licensed under the MIT License - see the LICENSE file for details.
- FSRS - Free Spaced Repetition Scheduler
- DuckDB - In-process analytical database
- OpenAI - AI language models
- Google Gemini - AI language models
- Author: Felipe Campos Penha
- Email: felipe.penha@alumni.usp.br
- GitHub: @felipepenha
- Issues: GitHub Issues