Spaces:
Sleeping
Sleeping
File size: 1,688 Bytes
383cb38 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #!/usr/bin/env python3
"""
Download Spacy English model for Presidio PII detection.
This script downloads the en_core_web_lg model required for
accurate PII detection using Microsoft Presidio.
Usage:
python scripts/download_spacy_model.py
Requirements:
pip install spacy
"""
import subprocess
import sys
def main():
"""Download Spacy English model (en_core_web_lg)"""
print("Downloading Spacy English model (en_core_web_lg)...")
print("This may take a few minutes...")
try:
# Download the model
subprocess.run(
[sys.executable, "-m", "spacy", "download", "en_core_web_lg"],
check=True,
capture_output=False,
text=True
)
print("\n✓ Spacy model downloaded successfully")
print("Presidio will use en_core_web_lg for PII detection")
print("\nModel features:")
print(" - 500k vocabulary size")
print(" - Word vectors (300-dimensional)")
print(" - Part-of-speech tagging")
print(" - Named entity recognition")
print(" - Dependency parsing")
return 0
except subprocess.CalledProcessError as e:
print(f"\n✗ Failed to download Spacy model: {e}")
print("\nTroubleshooting:")
print(" 1. Ensure you have internet connection")
print(" 2. Try: pip install spacy --upgrade")
print(" 3. Try: python -m spacy download en_core_web_lg directly")
print("\nFallback: Presidio will use smaller built-in models")
return 1
except Exception as e:
print(f"\n✗ Unexpected error: {e}")
return 1
if __name__ == "__main__":
sys.exit(main())
|