lbl/redaction
0
1import spacy2import os3import subprocess4import sys5 6MODELS = ["en_core_web_lg", "fr_core_news_lg"]7 8def check_and_download():9 for model in MODELS:10 try:11 print(f"๐ Checking if {model} is installed...")12 spacy.load(model)13 print(f"โ
{model} is already present.")14 except OSError:15 print(f"๐ฅ {model} not found. Downloading (this may take a few minutes)...")16 # Using --user to ensure it goes into a writable directory for non-root users17 subprocess.check_call([sys.executable, "-m", "spacy", "download", model, "--user"])18 print(f"โจ {model} downloaded successfully.")19 20if __name__ == "__main__":21 check_and_download()22 