Welcome to the Anki Flashcard Automation Tool! This project is designed to simplify the creation of engaging, visually enriched Anki flashcards by automating the process of sourcing high-quality images and integrating them with your vocabulary or learning material. Whether you are a student, educator, or lifelong learner, this tool provides an efficient and seamless way to enhance your flashcards.
With advanced features like synonym-based query expansion, natural language processing (NLP) enhancements, and metadata-driven image ranking, this tool ensures that every flashcard is both accurate and visually appealing. By leveraging the Pixabay API and intelligent search techniques, we bring together functionality and creativity to take your learning experience to the next level.
This project automates the creation of Anki flashcards enriched with images sourced from Pixabay.
The project creates Anki decks from input files containing words and their meanings, fetching images from Pixabay to include in the cards. The main.py script orchestrates the process, including directory setup, logging, input file selection, and deck creation. The anki_utils.py module provides functions to create decks, add notes, and export decks using the genanki library. The pixabay_api.py module handles interactions with the Pixabay API to fetch images based on queries. The file_utils.py and utils.py modules contain various utility functions for file operations, configuration management, and synonym handling.
Key functionalities include:
- Dynamic Query Expansion: Incorporates synonyms for richer search results.
- API Configuration: Easily manage and update API keys.
- Advanced Query Features:
- NLP-based refinement.
- Metadata-based ranking of results.
- Strict filtering options.
- Tag-based image searching.
- Efficient Caching: Avoid redundant API calls by implementing cache mechanisms.
- Logging and Debugging: Comprehensive logs ensure smooth monitoring and debugging.
- Synonym expansion powered by
datamuse
. - Local caching of synonyms to minimize redundant online lookups.
- Configurable via
synonyms.json
file.
- Retrieves high-quality images based on the refined queries.
- Advanced configuration options for filtering and sorting results.
- Lemmatization ensures more relevant searches.
- Configurable toggle to enable or disable NLP-based enhancements.
- Results are sorted by metadata attributes like likes, downloads, and views to ensure the best image is selected.
- Editor's choice filter for premium results.
- Tag-based query support for precise searches.
- Detailed logs for:
- Query expansions.
- API requests and responses.
- Cache hits, misses, and expirations.
- Dynamically relaxes filters (e.g., removes
editors_choice
) to retrieve more results if the initial query yields too few images.
- Install required Python libraries using:
pip install -r requirements.txt
- Obtain a Pixabay API key from Pixabay.
-
Copy
config.example.json
toconfig.json
:cp config.example.json config.json
- Save the Pixabay API key:
python main.py --save-key YOUR_API_KEY
- Configure
config.json
:{ "use_synonyms": true, "rank_by_metadata": true, "strict_filters": false, "apply_nlp": true, "tags": [] }
- Run the application:
python main.py
Logs are saved in the logs/
directory for debugging purposes.
To verify feature integration:
- Toggle feature settings in
config.json
. - Observe logs to ensure all layers are working together harmoniously.
- Use sample queries to validate:
- Synonym expansion.
- Metadata ranking.
- Tag filtering.
- Diversify image sourcing with additional APIs.
- Optimize performance for large datasets and complex queries.
- Enhance NLP processing with contextual understanding.
- Integrated NLP-based query refinement.
- Added tag-based filtering and stricter search controls.
- Improved metadata-based ranking.
- Implemented dynamic synonym expansion using
datamuse
. - Introduced caching for synonyms and API responses.
- Added Pixabay integration for fetching images.
- Basic query normalization and logging setup.
- Initial release with Anki deck generation and basic functionality.