API Reference
This page contains the complete API documentation for pranaam.
Main Functions
Entry point module for pranaam CLI.
-
pranaam.pranaam.main(argv=None)[source]
Main CLI entry point for religion prediction.
- Parameters:
argv (list[str] | None) – Command line arguments, defaults to sys.argv[1:]
- Returns:
Exit code (0 for success, non-zero for error)
- Return type:
int
- Raises:
SystemExit – For help and argument parsing errors
Core Classes
Naam Class
Main prediction module for religion classification.
-
pranaam.naam.is_english(text)[source]
Check if text contains only ASCII characters (English).
- Parameters:
text (str) – Input text to check
- Returns:
True if text is ASCII-only (English), False otherwise
- Return type:
bool
-
class pranaam.naam.Naam[source]
Bases: Base
Main class for religion prediction from names.
-
MODELFN: str = 'model'
-
weights_loaded: bool = False
-
model: Model | None = None
-
model_path: Path | None = None
-
classes: Final[list[str]] = ['not-muslim', 'muslim']
-
cur_lang: str = 'eng'
-
model_name: Final[str] = 'eng_and_hindi_models_v2'
-
classmethod pred_rel(names, lang='eng', latest=False)[source]
Predict religion based on name(s).
- Parameters:
names (str | list[str] | Series) – Single name string, list of names, or pandas Series of names
lang (Literal['eng', 'hin']) – Language of input (‘eng’ for English, ‘hin’ for Hindi)
latest (bool) – Whether to download latest model version
- Returns:
DataFrame with columns: name, pred_label, pred_prob_muslim
- Return type:
pd.DataFrame
- Raises:
-
Base Class
-
class pranaam.base.Base[source]
Bases: object
Base class for model data management and loading.
-
MODELFN: str | None = None
-
classmethod load_model_data(file_name, latest=False)[source]
Load model data, downloading if necessary.
- Parameters:
-
- Returns:
Path to the model directory, or None if loading failed
- Return type:
Path | None
Utility Functions
Utilities for downloading and extracting model files.
-
pranaam.utils.download_file(url, target, file_name)[source]
Download and extract a model file from the given URL.
- Parameters:
url (str) – Base URL (not currently used, uses REPO_BASE_URL instead)
target (str) – Target directory for extraction
file_name (str) – Name of the file to download
- Returns:
True if download and extraction successful, False otherwise
- Return type:
bool
-
exception pranaam.utils.SecurityError[source]
Bases: Exception
Raised when a security violation is detected.
Logging Configuration
Logging configuration for pranaam package.
-
pranaam.logging.get_logger(name=None)[source]
Get a configured logger instance.
- Parameters:
name (str | None) – Logger name, defaults to ‘pranaam’
- Returns:
Configured logger instance
- Return type:
logging.Logger