fuzzy_dl_owl2.fuzzydl.util.config_reader

A centralized configuration manager that loads and applies settings for a fuzzy reasoning engine from INI or environment files.

Description

The software establishes a set of default parameters governing the behavior of a fuzzy reasoning engine, including precision thresholds, optimization levels, and blocking strategies. It provides a flexible loading mechanism that prioritizes a specified INI configuration file but falls back to a .env file located in the current working directory if the primary source is unavailable. Input values are normalized to handle case and underscore variations, ensuring compatibility between different configuration formats, while specific overrides can be applied directly to the loaded settings. Once the parameters are loaded, the system automatically derives internal precision metrics and adjusts global numerical limits within the application to match the specific capabilities of the chosen Mixed-Integer Linear Programming solver.

Classes

ConfigReader

A centralized configuration manager for a reasoning engine, defining default parameters that control precision, optimization levels, blocking strategies, and the selection of the Mixed-Integer Linear Programming (MILP) solver. It allows users to customize the reasoner's behavior by loading settings from a configuration file (INI) or, when that file is missing or unspecified, from a .env file located in the current working directory. Specific values can be overridden via command-line arguments. When parameters are loaded, the manager automatically adjusts internal precision calculations and updates global constants within the application to match the capabilities of the selected solver provider.

Module Contents

UML Class Diagram for ConfigReader

UML Class Diagram for ConfigReader

class ConfigReader[source]

A centralized configuration manager for a reasoning engine, defining default parameters that control precision, optimization levels, blocking strategies, and the selection of the Mixed-Integer Linear Programming (MILP) solver. It allows users to customize the reasoner’s behavior by loading settings from a configuration file (INI) or, when that file is missing or unspecified, from a .env file located in the current working directory. Specific values can be overridden via command-line arguments. When parameters are loaded, the manager automatically adjusts internal precision calculations and updates global constants within the application to match the capabilities of the selected solver provider.

Parameters:
  • ANYWHERE_DOUBLE_BLOCKING (bool) – Determines whether the anywhere double blocking optimization is applied.

  • ANYWHERE_SIMPLE_BLOCKING (bool) – Determines whether anywhere simple blocking is applied during reasoning.

  • DEBUG_PRINT (bool) – Flag to enable or disable the printing of debug messages to the console.

  • EPSILON (float) – Precision threshold defining the minimum degree of satisfaction required for a concept to be considered satisfied by an individual.

  • MAX_INDIVIDUALS (int) – Defines the maximum number of new individuals that can be generated during reasoning. A negative value disables this limit, allowing unlimited creation.

  • NUMBER_DIGITS (int) – Number of digits of precision, computed from the epsilon value to define the decimal places required for the reasoner’s operations.

  • OPTIMIZATIONS (int) – Level of optimizations applied. A value of 0 disables optimizations, while a positive value enables them. Default is 1.

  • RULE_ACYCLIC_TBOXES (bool) – Enables the rule acyclic TBox optimization.

  • OWL_ANNOTATION_LABEL (str) – The XML annotation label used to identify fuzzy logic constructs when creating or parsing Fuzzy OWL 2 ontologies.

  • MILP_PROVIDER (constants.MILPProvider) – Specifies the Mixed-Integer Linear Programming (MILP) solver backend used by the reasoner for optimization tasks, influencing internal numerical limits based on the selected provider.

static _read_env() dict[str, str] | None[source]

Loads the default .env discovered by python-dotenv.

python-dotenv’s default find_dotenv() walks up from the caller’s file (config_reader.py), not from the current working directory, so a .env placed in the user’s working directory was previously invisible. Pass usecwd=True so discovery starts at os.getcwd() and walks up from there.

Returns:

The file-only key/value mapping, or None when no .env file is discovered.

Return type:

dict[str, str] | None

static _read_ini(config_file: str) dict[str, str][source]

Reads an INI-style configuration file and returns the key/value pairs of its DEFAULT section as a plain dictionary. Parsing is delegated to configparser.ConfigParser; if the file cannot be found or read, a FileNotFoundError is raised rather than silently returning an empty mapping.

Parameters:

config_file (str) – Path to the INI configuration file to read.

Raises:

FileNotFoundError – if the configuration file does not exist or cannot be read.

Returns:

The DEFAULT section entries as a {key: value} mapping.

Return type:

dict[str, str]

static load_parameters(config_file: str | None, **kwargs: list[str]) None[source]

Loads configuration settings and applies overrides from the provided argument list.

When config_file is None or points to a non-existent path, the loader falls back to a .env file located in the current working directory (./.env). The .env file uses the standard KEY=VALUE format; keys are matched against the INI configuration keys in a case- and underscore-insensitive way, so either DEBUG_PRINT=True or debugPrint=True is accepted.

Overrides are supplied as keyword arguments and applied on top of the values read from the INI/.env source before case- and underscore-insensitive normalisation.

Parameters:
  • config_file (str | None) – Filesystem path to the INI configuration file. If None or missing, ./.env is used as a fallback.

  • kwargs (dict[str, Any]) – A dictionary of key-value pairs to override configuration settings.

Raises:

FileNotFoundError – if config_file is None or missing and no .env file can be discovered by python-dotenv.

ANYWHERE_DOUBLE_BLOCKING: bool = True
ANYWHERE_SIMPLE_BLOCKING: bool = True
DEBUG_PRINT: bool = False
EPSILON: float = 0.001
MAX_INDIVIDUALS: int = -1
MILP_PROVIDER: fuzzy_dl_owl2.fuzzydl.util.constants.MILPProvider
NUMBER_DIGITS: int = 2
OPTIMIZATIONS: int = 1
OWL_ANNOTATION_LABEL: str = 'fuzzyLabel'
RULE_ACYCLIC_TBOXES: bool = True