Download docs/GLOSSARY_EXTRACTION_QUICKSTART.md from Norelad/TraductAL: direct link, hf CLI and curl.
- Browser
- Download file 10 kB
-
https://huggingface.co/spaces/Norelad/TraductAL/resolve/main/docs/GLOSSARY_EXTRACTION_QUICKSTART.md
- Command line
-
hf download hf://spaces/Norelad/TraductAL/docs/GLOSSARY_EXTRACTION_QUICKSTART.md
-
curl -L -o GLOSSARY_EXTRACTION_QUICKSTART.md https://huggingface.co/spaces/Norelad/TraductAL/resolve/main/docs/GLOSSARY_EXTRACTION_QUICKSTART.md
A newer version of the Gradio SDK is available: 6.32.0
π Glossary Extraction Quick Start
Your situation: You have Glossaire vaudois (1861) PDF Your goal: Extract lexical data β Import to Swiss French dataset Expected result: ~1,000-2,000 training examples
β‘ 3-Step Quick Start
Step 1: Install PDF Library (30 seconds)
# Install PyPDF2 (easiest)
pip install PyPDF2
# Or install all three for best compatibility
pip install PyPDF2 pdfplumber pymupdf
Step 2: Test Your PDF (1 minute)
# Replace with your actual PDF filename
./test_pdf_extraction.sh glossaire_vaudois_1861.pdf vaud
This will tell you:
- β Is text extractable?
- β Does it need OCR?
- β Where does the glossary start?
- β What patterns are present?
Step 3: Extract (2-5 minutes)
If test shows "Ready for extraction":
python3 glossary_extractor.py \
--pdf glossaire_vaudois_1861.pdf \
--dialect vaud
If test shows "Need OCR":
# Install OCR tool
pip install ocrmypdf
# Run OCR (creates searchable PDF)
ocrmypdf glossaire_vaudois_1861.pdf glossaire_vaudois_1861_ocr.pdf --language fra
# Then extract
python3 glossary_extractor.py \
--pdf glossaire_vaudois_1861_ocr.pdf \
--dialect vaud
Result: CSV file at datasets/swiss_french/Raw_Data/extracted_vaud_glossary.csv
π What You'll See
During Extraction
π Extracting text from: glossaire_vaudois_1861.pdf
Pages: 250
β
Extracted 245,892 characters
π§Ή Cleaning text...
Cleaned 3,847 lines from 4,123 total
π Identifying glossary start...
Found glossary start at line 145: ABAISER, v. Abaisser
π Parsing entries from line 145...
β
Parsed 1,247 entries
β¨ Enriching entries...
β
Enriched 1,247 entries
============================================================
π EXTRACTION STATISTICS
============================================================
PDF file: glossaire_vaudois_1861.pdf
Dialect: vaud
Total entries extracted: 1,247
Part of speech distribution:
masculine noun: 542
feminine noun: 423
verb: 187
adjective: 95
Entries with standard French: 892 (71.5%)
Sample entries:
PANOSSE (feminine noun): Serpillière pour laver le sol...
LINGE (masculine noun): Serviette de toilette...
πΎ Saving to CSV: datasets/swiss_french/Raw_Data/extracted_vaud_glossary.csv
β
Saved 1,247 entries
π Next step:
python3 swiss_french_dataset_builder.py --dialect vaud --import-csv datasets/swiss_french/Raw_Data/extracted_vaud_glossary.csv
CSV Output Format
swiss_french,standard_french,dialect,part_of_speech,definition,source,notes
panosse,serpillière,vaud,feminine noun,Serpillière pour laver le sol,Glossaire vaud (1861),Line 150
linge,serviette,vaud,masculine noun,Serviette de toilette,Glossaire vaud (1861),Line 151
ça joue,ça va,vaud,expression,Manière de saluer familière,Glossaire vaud (1861),Line 243
π― After Extraction: Import to Dataset
# Import the CSV
python3 swiss_french_dataset_builder.py \
--dialect vaud \
--import-csv datasets/swiss_french/Raw_Data/extracted_vaud_glossary.csv
# Check your progress
python3 swiss_french_dataset_builder.py --stats
Expected output: ```
π DATASET STATISTICS
sft_dictionary_vaud.jsonl: 2,494 examples
β Total examples: 2,494 π Location: TraductAL-v1.1.0/datasets/swiss_french
π Progress vs. Romansh dataset (46,092 examples): Current: 5.4% π― Next milestone: 5,000 examples (dictionary focus)
**Impact**: 1,247 entries β 2,494 training examples (bidirectional)
---
## π§ Common Issues & Solutions
### Issue 1: No Text Extracted
**Symptom:**
π Extracting text from: glossaire.pdf Pages: 250 β Extracted 0 characters
**Cause**: PDF is image-based (scanned), not searchable
**Solution**: Run OCR
```bash
# Install
pip install ocrmypdf
# Run OCR (French language)
ocrmypdf glossaire_vaudois_1861.pdf glossaire_vaudois_1861_ocr.pdf --language fra
# Extract from OCR'd version
python3 glossary_extractor.py --pdf glossaire_vaudois_1861_ocr.pdf --dialect vaud
Alternative: Use Google Drive
- Upload PDF to Google Drive
- Right-click β Open with Google Docs
- File β Download β PDF
- Extract from the downloaded PDF
Issue 2: Few Entries Found
Symptom:
π Parsing entries from line 0...
β
Parsed 23 entries
Cause: Extraction started too early (preface, table of contents)
Solution: Manual start line
# Save raw text
python3 glossary_extractor.py --pdf glossaire.pdf --save-raw raw.txt
# Open and find where glossary starts
less raw.txt
# Look for first entry like "ABAISER" or "A." section marker
# Extract from correct line (e.g., line 145)
python3 glossary_extractor.py \
--raw-text raw.txt \
--start-line 145 \
--dialect vaud
Issue 3: Garbled Characters
Symptom:
panosse,serpilli̬ère,vaud,...
Cause: OCR errors or encoding issues
Solution A: Try different PDF library
# Install pymupdf (often better for OCR)
pip install pymupdf
# Re-extract
python3 glossary_extractor.py --pdf glossaire.pdf --dialect vaud
Solution B: Manual cleanup in CSV
# Extract
python3 glossary_extractor.py --pdf glossaire.pdf --output temp.csv
# Open in LibreOffice/Excel and fix manually
libreoffice temp.csv
# Then import
python3 swiss_french_dataset_builder.py --dialect vaud --import-csv temp.csv
π‘ Pro Tips
Tip 1: Always Test First
# Test with small sample
./test_pdf_extraction.sh glossaire.pdf vaud
# Review output before full extraction
Tip 2: Save Raw Text
# Always save raw text for review
python3 glossary_extractor.py \
--pdf glossaire.pdf \
--save-raw raw_vaud_text.txt \
--dialect vaud
# You can reprocess without re-extracting PDF
python3 glossary_extractor.py \
--raw-text raw_vaud_text.txt \
--dialect vaud
Tip 3: Manual Review is OK
Don't expect 100% automatic accuracy:
- 80-90% automatic extraction is great
- 10-20% manual cleanup is normal
- Quality > quantity
Tip 4: Iterate
- Extract first pass
- Review sample entries
- Adjust if needed
- Re-extract
- Manual cleanup
- Import
π Expected Results by PDF Quality
| PDF Type | Auto Extraction | Manual Work | Total Time |
|---|---|---|---|
| Modern, searchable | 95% | 5% | 10 min |
| OCR'd (good quality) | 85% | 15% | 30 min |
| OCR'd (poor quality) | 70% | 30% | 1-2 hours |
| Image-only (no OCR) | 0% β OCR needed | - | +15 min OCR |
Your Glossaire vaudois (1861): Likely "OCR'd (good quality)" category
- Expected: 1,000-1,500 entries automatically
- Manual cleanup: 100-300 entries
- Total time: 30-60 minutes
π― Realistic Expectations
From One 1861 Glossary
Input: Glossaire vaudois (1861), ~250 pages
Automatic extraction:
- 1,200 entries (80% success rate)
- 2,400 training examples (bidirectional)
After manual cleanup (1-2 hours):
- 1,500 entries (includes manual fixes)
- 3,000 training examples
With additional processing:
- Add example sentences: +1,500 examples
- Add idiom identification: +500 examples
- Total: ~5,000 examples from one glossary!
β Success Checklist
After extraction, verify:
- CSV file created with entries
- Entry count reasonable (500+)
- Sample entries look correct
- Standard French column has values (>50%)
- No major OCR errors (???, garbled text)
If all checked: Import to dataset!
python3 swiss_french_dataset_builder.py \
--dialect vaud \
--import-csv extracted_vaud_glossary.csv
python3 swiss_french_dataset_builder.py --stats
π Next Steps
Immediate (Today)
- β
Test your PDF:
./test_pdf_extraction.sh glossaire_vaudois_1861.pdf vaud - β
Run OCR if needed:
ocrmypdf input.pdf output_ocr.pdf --language fra - β
Extract:
python3 glossary_extractor.py --pdf glossaire.pdf --dialect vaud - β
Import:
python3 swiss_french_dataset_builder.py --dialect vaud --import-csv extracted.csv
This Week
- Find more glossaries (Geneva, Fribourg, NeuchΓ’tel)
- Extract each one
- Target: 5,000 total examples
This Month
- Generate synthetic data (fill gaps)
- Human validation
- Target: 20,000 examples (production-ready)
π Need Help?
Documentation:
- Full guide:
PDF_GLOSSARY_EXTRACTION_GUIDE.md - This quickstart:
GLOSSARY_EXTRACTION_QUICKSTART.md - Dataset guide:
SWISS_FRENCH_DATASET_GUIDE.md
Test commands:
# Test PDF
./test_pdf_extraction.sh your_glossary.pdf vaud
# Get help
python3 glossary_extractor.py --help
Common commands:
# Basic extraction
python3 glossary_extractor.py --pdf glossary.pdf --dialect vaud
# With OCR
ocrmypdf glossary.pdf glossary_ocr.pdf --language fra
python3 glossary_extractor.py --pdf glossary_ocr.pdf --dialect vaud
# Save raw text for review
python3 glossary_extractor.py --pdf glossary.pdf --save-raw raw.txt
# Process raw text
python3 glossary_extractor.py --raw-text raw.txt --dialect vaud
# Import to dataset
python3 swiss_french_dataset_builder.py --dialect vaud --import-csv extracted.csv
π Summary
What you have:
- β Glossaire vaudois (1861) PDF
- β
Extraction tool (
glossary_extractor.py) - β
Test script (
test_pdf_extraction.sh) - β Import pipeline (dataset builder)
What to do:
- Test PDF (1 minute)
- Run OCR if needed (5-15 minutes)
- Extract glossary (2-5 minutes)
- Import to dataset (1 minute)
Expected result:
- 1,000-1,500 dictionary entries
- 2,000-3,000 training examples
- Major progress toward 5,000-example milestone!
Time investment: 30-60 minutes total
Your glossary is a goldmine - let's extract it! ππβπ