The French Vocabulary LaTeX Builder is a Python application designed to help users create and maintain a LaTeX document for French vocabulary. It leverages AI-powered assistance to generate definitions and examples for French words, formatting them into LaTeX entries and inserting them into a specified file. Additionally, the tool offers seamless export to Anki decks for efficient learning.
Before you begin, ensure you have the following installed:
- Python 3.7 or higher
- pip (Python package installer)
- An Anthropic API key for Claude AI integration
You need to set your Anthropic API key as an environment variable. Follow the instructions for your operating system:
-
Open the Terminal.
-
Run the following command, replacing
your-api-key-here
with your actual API key:export ANTHROPIC_API_KEY='your-api-key-here'
-
To make this change permanent, follow these steps:
a. Open your shell configuration file using nano. Depending on your shell, run one of these commands:
- For Bash:
nano ~/.bash_profile
ornano ~/.bashrc
- For Zsh:
nano ~/.zshrc
b. Add the following line to the end of the file:
export ANTHROPIC_API_KEY='your-api-key-here'
Replace 'your-api-key-here' with your actual Anthropic API key.
c. Save the file and exit nano:
- Press
Ctrl + X
- Press
Y
to confirm saving - Press
Enter
to keep the same filename
d. To apply the changes immediately, run the following command in your terminal:
source ~/.zshrc # If using Zsh
or
source ~/.bash_profile # If using Bash
This will make the API key available in all new terminal sessions.
- For Bash:
-
Open Command Prompt or PowerShell.
-
Run the following command, replacing
your-api-key-here
with your actual API key:setx ANTHROPIC_API_KEY "your-api-key-here"
-
Restart your Command Prompt or PowerShell to apply the changes.
-
Clone the repository or download the source code:
git clone https://github.com/Razeberry/frenchvocab.git cd frenchvocab
-
Install the required Python packages:
pip install -r requirements.txt
The French Vocabulary LaTeX Builder includes automatic setup and configuration:
-
First-time Setup:
- On the first run, if the ANTHROPIC_API_KEY is not set in the environment variables, the program will attempt to retrieve it from the system's secure keyring.
- If the API key is not found in the keyring, the program will guide you through the process of obtaining and entering a valid Anthropic API key.
- The API key will be securely stored in the system's keyring for future use.
- The program will validate the API key before proceeding.
-
Automatic LaTeX File Generation:
- If the LaTeX file doesn't exist, the program will automatically create it with the necessary structure.
- The default filename is
FrenchVocab.tex
in the current working directory.
No manual configuration is required for basic usage. The program will guide you through the setup process on its first run.
To run the French Vocabulary LaTeX Builder:
-
Open a terminal and navigate to the project directory.
-
Run the script:
python FrenchVocab.py
-
Follow the on-screen prompts to add new words, search existing entries, export to Anki decks, or exit the program.
- Enter a French word or short expression.
- The AI will provide:
- Word type
- English definitions
- Example sentences in French with English translations
- The information is formatted into a LaTeX entry and inserted into your file.
- Entries are automatically sorted alphabetically in the LaTeX file.
- The system checks for duplicates and offers options to skip, view, or force add the entry.
- Utilizes Claude AI to generate accurate definitions and contextual examples.
- Export your vocabulary list to Anki decks for efficient learning and review.
- Steps to Export:
- Select the option to export to Anki from the main menu.
- Enter a name for your Anki deck when prompted.
- The program will generate an
.apkg
file with your vocabulary entries. - The
.apkg
file can be imported directly into Anki.
- API Key Issues: Ensure your Anthropic API key is correctly set as an environment variable.
- File Not Found Error: Double-check the path to your LaTeX file in the
main()
function. - Unicode Errors: Make sure your terminal supports UTF-8 encoding for proper display of French characters.
- Anki Export Errors: Ensure that the LaTeX file exists and contains valid entries before attempting to export.
For additional help, refer to the GitHub Issues page.