Setup Guide

Complete setup instructions for the Dictionary system. Environment configuration, dependencies, and troubleshooting.

Setup Guide

🎉 SOLVED: Easy Script Execution from Anywhere

✅ What Was Fixed

Problem: Running scripts from wrong directories with complex relative paths and missing dependencies.

Solution:

  1. Installed all required Python packages in your ags-dictionary conda environment
  2. Created wrapper scripts that work from ANY directory
  3. Clear documentation and aliases

🚀 How to Use Now

From ANY directory in your project:

1# 1. Activate your conda environment
2conda activate ags-dictionary
3
4# 2. Run the wrapper script (absolute path)
5/home/ag-sayyed/Documents/projects/hbstack/ghafoors-blog/scripts/dictionary/dict-extract.sh \
6  --video-url "https://www.youtube.com/watch?v=9M_dq_0ljsc" \
7  --topic "capitalism" \
8  --create-hugo-page \
9  --source-name "Capitalism is not natural"

That’s it! The script handles all paths correctly.


🎯 Even Easier - Create an Alias

Add this to your ~/.bashrc:

1# Dictionary extraction tool
2alias dict-extract="/home/ag-sayyed/Documents/projects/hbstack/ghafoors-blog/scripts/dictionary/dict-extract.sh"

Then reload:

1source ~/.bashrc

Now you can run from ANYWHERE:

1conda activate ags-dictionary
2
3dict-extract \
4  --video-url "https://www.youtube.com/watch?v=9M_dq_0ljsc" \
5  --topic "capitalism" \
6  --create-hugo-page \
7  --source-name "Capitalism is not natural"

📋 What Got Installed

In your ags-dictionary conda environment:

  • youtube-transcript-api - Fetch YouTube transcripts
  • openai - GPT-4 API access
  • PyYAML - YAML file handling
  • python-dotenv - Environment variable management
  • requests - HTTP requests
  • beautifulsoup4 - HTML parsing (optional)

📂 New Files Created

In Project Root

  1. scripts/dictionary/dict-extract.sh - Main wrapper script (RECOMMENDED)

    • Shell script that changes to project root before running
    • Works from any directory
    • Passes all arguments through
  2. scripts/dictionary/extract_vocab.py - Python wrapper

    • Alternative if you prefer Python
    • Same functionality

🔑 One More Thing - Set Your API Key

You need an OpenAI API key to use the script. Set it one of these ways:

1echo 'export OPENAI_API_KEY="sk-your-key-here"' >> ~/.bashrc
2source ~/.bashrc

Option 2: In Project Root .env File

1cat > /home/ag-sayyed/Documents/projects/hbstack/ghafoors-blog/.env << 'EOF'
2OPENAI_API_KEY=sk-your-key-here
3EOF

Option 3: In scripts/dictionary/.env

1cat > /home/ag-sayyed/Documents/projects/hbstack/ghafoors-blog/scripts/dictionary/.env << 'EOF'
2OPENAI_API_KEY=sk-your-key-here
3EOF

Get your API key from: https://platform.openai.com/api-keys


✅ Verification

Test that everything works:

1# Activate environment
2conda activate ags-dictionary
3
4# Check dependencies
5python -c "import yaml, openai, youtube_transcript_api; print('✅ All good!')"
6
7# Check script help
8/home/ag-sayyed/Documents/projects/hbstack/ghafoors-blog/scripts/dictionary/dict-extract.sh --help

🎬 Ready to Extract Vocabulary

Your fixed command (works from anywhere):

1conda activate ags-dictionary
2
3/home/ag-sayyed/Documents/projects/hbstack/ghafoors-blog/dict-extract.sh \
4  --video-url "https://www.youtube.com/watch?v=9M_dq_0ljsc" \
5  --topic "capitalism" \
6  --create-hugo-page \
7  --source-name "Capitalism is not natural"

What Will Happen

  1. Script fetches video transcript from YouTube
  2. GPT-4 analyzes and extracts 25 difficult words
  3. Translates to Urdu with examples
  4. Creates data/dictionary/capitalism/vocabulary.yaml
  5. Creates content/docs/dictionary/capitalism/index.md
  6. You review and edit if needed
  7. Test with npm run dev:memory
  8. Done!

Time: 5-10 minutes (most is AI processing)


📚 Next Steps

  1. Follow the Getting Started Checklist for verification
  2. See Step-by-Step Guide for detailed workflow

🎉 Summary

Before

  • ❌ Running from wrong directory
  • ❌ Complex relative paths
  • ❌ Missing Python packages
  • ❌ Confusing error messages

After

  • ✅ Run from ANY directory
  • ✅ Simple wrapper scripts
  • ✅ All dependencies installed
  • ✅ Clear documentation
  • ✅ Easy alias setup

You’re all set! 🚀


Created: 2026-05-05
Issue: Path resolution and missing dependencies
Status: ✅ RESOLVED