Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "secureml"
version = "0.2.1"
version = "0.2.2"
description = "A Python library for privacy-preserving machine learning"
authors = ["Enzo Paloschi Biondo <enzobiondo11@outlook.com>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion secureml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
while maintaining compliance with privacy regulations like GDPR, CCPA, and HIPAA.
"""

__version__ = "0.2.1"
__version__ = "0.2.2"

# Export core functions for easier imports
from secureml.anonymization import anonymize
Expand Down
25 changes: 20 additions & 5 deletions secureml/compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def get_nlp_model(model_name: str = "en_core_web_sm") -> Language:
Load and return a SpaCy NLP model.

This function caches the model to avoid reloading it multiple times.
If the model is not installed, it will attempt to download and install it.

Args:
model_name: Name of the SpaCy model to load
Expand All @@ -32,18 +33,32 @@ def get_nlp_model(model_name: str = "en_core_web_sm") -> Language:
Loaded SpaCy language model

Raises:
ImportError: If the specified model is not installed
ImportError: If the specified model cannot be installed or loaded
"""
global _NLP_MODEL

if _NLP_MODEL is None:
try:
_NLP_MODEL = spacy.load(model_name)
except OSError:
raise ImportError(
f"SpaCy model '{model_name}' not found. "
f"Please install it with: python -m spacy download {model_name}"
)
# Model not found, attempt to install it
print(f"SpaCy model '{model_name}' not found. Attempting to download and install...")
try:
import subprocess
import sys

# Run the spacy download command
subprocess.check_call([sys.executable, "-m", "spacy", "download", model_name])

# Try loading the model again
_NLP_MODEL = spacy.load(model_name)
print(f"Successfully installed and loaded model '{model_name}'.")
except Exception as e:
raise ImportError(
f"Failed to automatically install SpaCy model '{model_name}'. "
f"Error: {str(e)}. "
f"Please install it manually with: python -m spacy download {model_name}"
)

return _NLP_MODEL

Expand Down
2 changes: 1 addition & 1 deletion source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = 'SecureML'
copyright = '2025, Enzo Biondo'
author = 'Enzo Biondo'
release = '0.2.0'
release = '0.2.2'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down