@@ -27,8 +27,8 @@ ontouml_models_lib.catalog
2727 --------
2828 Example 1: Loading a Catalog and Executing a Single Query on All Models
2929
30- >>> from catalog import Catalog
31- >>> from query import Query
30+ >>> from ontouml_models_lib import Catalog
31+ >>> from ontouml_models_lib import Query
3232
3333 >>> # Initialize the catalog with the path to the directory
3434 >>> catalog = Catalog(' /path/to/catalog' )
@@ -41,8 +41,8 @@ ontouml_models_lib.catalog
4141
4242 Example 2: Filtering Models by Attributes and Executing Multiple Queries
4343
44- >>> from catalog import Catalog
45- >>> from query import Query
44+ >>> from ontouml_models_lib import Catalog
45+ >>> from ontouml_models_lib import Query
4646
4747 >>> # Initialize the catalog
4848 >>> catalog = Catalog(' /path/to/catalog' )
@@ -58,8 +58,8 @@ ontouml_models_lib.catalog
5858
5959 Example 3: Executing Multiple Queries on a Specific Model
6060
61- >>> from catalog import Catalog
62- >>> from query import Query
61+ >>> from ontouml_models_lib import Catalog
62+ >>> from ontouml_models_lib import Query
6363
6464 >>> # Initialize the catalog
6565 >>> catalog = Catalog(' /path/to/catalog' )
@@ -121,8 +121,8 @@ Module Contents
121121 --------
122122 Basic usage example of the `Catalog ` class:
123123
124- >>> from catalog import Catalog
125- >>> from query import Query
124+ >>> from ontouml_models_lib import Catalog
125+ >>> from ontouml_models_lib import Query
126126
127127 >>> # Initialize the catalog with the path to the directory
128128 >>> catalog = Catalog(' /path/to/catalog' )
@@ -183,8 +183,8 @@ Module Contents
183183
184184 Example usage:
185185
186- >>> from catalog import Catalog
187- >>> from query import Query
186+ >>> from ontouml_models_lib import Catalog
187+ >>> from ontouml_models_lib import Query
188188 >>> catalog = Catalog(' /path/to/catalog' )
189189 >>> query = Query(' ./queries/query.sparql' ) # Load a SPARQL query from a file
190190 >>> model = catalog.get_model(' some_model_id' ) # Retrieve a model by its ID
@@ -210,8 +210,8 @@ Module Contents
210210
211211 Example usage:
212212
213- >>> from catalog import Catalog
214- >>> from query import Query
213+ >>> from ontouml_models_lib import Catalog
214+ >>> from ontouml_models_lib import Query
215215 >>> catalog = Catalog(' /path/to/catalog' )
216216 >>> query = Query(' ./queries/query.sparql' ) # Load a SPARQL query from a file
217217 >>> catalog.execute_query_on_all_models(query) # Execute the query on all models
@@ -238,8 +238,8 @@ Module Contents
238238
239239 Example usage:
240240
241- >>> from catalog import Catalog
242- >>> from query import Query
241+ >>> from ontouml_models_lib import Catalog
242+ >>> from ontouml_models_lib import Query
243243 >>> catalog = Catalog(' /path/to/catalog' )
244244 >>> model = catalog.get_model(' some_model_id' ) # Retrieve a model by its ID
245245 >>> queries = Query.load_queries(' ./queries' ) # Load multiple SPARQL queries from a directory
@@ -268,8 +268,8 @@ Module Contents
268268
269269 Example usage:
270270
271- >>> from catalog import Catalog
272- >>> from query import Query
271+ >>> from ontouml_models_lib import Catalog
272+ >>> from ontouml_models_lib import Query
273273 >>> catalog = Catalog(' /path/to/catalog' )
274274 >>> models = catalog.get_models(language = " en" ) # Filter models by language
275275 >>> queries = Query.load_queries(' ./queries' ) # Load multiple SPARQL queries from a directory
@@ -296,8 +296,8 @@ Module Contents
296296
297297 Example usage:
298298
299- >>> from catalog import Catalog
300- >>> from query import Query
299+ >>> from ontouml_models_lib import Catalog
300+ >>> from ontouml_models_lib import Query
301301 >>> catalog = Catalog(' /path/to/catalog' )
302302 >>> queries = Query.load_queries(' ./queries' ) # Load multiple SPARQL queries from a directory
303303 >>> catalog.execute_queries_on_all_models(queries) # Execute the queries on all models
@@ -319,7 +319,7 @@ Module Contents
319319
320320 Example usage:
321321
322- >>> from catalog import Catalog
322+ >>> from ontouml_models_lib import Catalog
323323 >>> catalog = Catalog(' /path/to/catalog' )
324324 >>> model = catalog.get_model(' some_model_id' ) # Retrieve a model by its unique ID
325325
@@ -343,7 +343,7 @@ Module Contents
343343
344344 Example usage:
345345
346- >>> from catalog import Catalog
346+ >>> from ontouml_models_lib import Catalog
347347 >>> catalog = Catalog(' /path/to/catalog' )
348348 >>> # Filter models by a single attribute (language)
349349 >>> filtered_models = catalog.get_models(language = " en" )
@@ -367,68 +367,100 @@ Module Contents
367367
368368 Example usage:
369369
370- >>> from catalog import Catalog
370+ >>> from ontouml_models_lib import Catalog
371371 >>> catalog = Catalog(' /path/to/catalog' )
372372 >>> catalog.remove_model_by_id(' some_model_id' ) # Remove a model by its unique ID
373373
374374
375375
376376 .. py :method :: _load_models()
377377
378- Load all ontology models from the specified directory.
378+ Load all ontology models from the catalog directory.
379379
380- This method is called internally by the initializer to scan the catalog directory for subfolders, each
381- representing an ontology model. It loads the models from these subfolders and initializes them as instances of
382- the `Model ` class. The loaded models are stored in the `models ` attribute .
380+ This method scans the catalog directory for subfolders, each representing an ontology model. It loads the models
381+ from these subfolders and initializes them as instances of the ` Model ` class. The loaded models are stored in
382+ the `models ` attribute of the `Catalog ` instance .
383383
384- :raises FileNotFoundError: If the catalog path does not contain any model subfolders.
384+ :raises FileNotFoundError: If the catalog directory does not contain any model subfolders.
385385
386386
387387
388388 .. py :method :: _get_subfolders()
389389
390- Get the names of all subfolders in the catalog catalog_path.
390+ Retrieve the names of all subfolders in the catalog directory.
391+
392+ This method identifies all subfolders within the catalog's `path_models ` directory, which represent individual
393+ ontology models. The subfolders are expected to have the necessary ontology and metadata files for each model.
394+
395+ :return: A list of subfolder names within the catalog directory.
396+ :rtype: list
391397
392398
393399
394400 .. py :method :: _create_catalog_graph()
395401
396- Create a single RDFLib model_graph by merging all graphs from the models.
402+ Create a merged RDFLib graph from all loaded models in the catalog.
403+
404+ This method combines the RDF graphs of all loaded models into a single RDFLib `Graph ` object. The merged graph
405+ allows for executing SPARQL queries across the entire catalog, enabling comprehensive queries that span multiple
406+ models.
407+
408+ :return: A merged RDFLib graph containing all triples from the models in the catalog.
409+ :rtype: Graph
397410
398411
399412
400413 .. py :method :: _generate_compiled_results(results, compiled_file_path)
401414
402- Generate a compiled CSV file from results of all models.
415+ Generate a compiled CSV file from the results of all models.
416+
417+ This method compiles the results of SPARQL queries executed across multiple models into a single CSV file.
418+ The compiled file is saved at the specified `compiled_file_path `. The method ensures that the results are
419+ formatted as a tabular dataset, with the `model_id ` column appearing first.
420+
421+ :param results: A list of dictionaries containing the results from multiple models.
422+ :type results: list[dict]
423+ :param compiled_file_path: The path where the compiled CSV file will be saved.
424+ :type compiled_file_path: Path
403425
404426
405427
406428 .. py :method :: _match_model(model, filters, operand)
407429
408- Check if a model matches the given attribute restrictions.
430+ Check if a model matches the specified attribute filters.
431+
432+ This method evaluates whether a model meets the attribute restrictions defined in the `filters ` dictionary.
433+ It supports combining multiple filters using logical operations ("and" or "or"), and returns a boolean
434+ indicating whether the model satisfies the filter conditions.
409435
410- :param model: The model to check .
436+ :param model: The model to be checked against the filters .
411437 :type model: Model
412- :param filters: Attribute restrictions to filter models.
413- :type filters: dict
414- :param operand: Logical operand for combining filters ("and" or "or").
438+ :param filters: A dictionary of attribute restrictions used to filter models. Attribute names and values are
439+ passed as keyword arguments.
440+ :type filters: dict[str, Any]
441+ :param operand: Logical operand for combining filters ("and" or "or"). Defaults to "and".
415442 :type operand: str
416- :return: True if the model matches the restrictions, False otherwise.
443+ :return: True if the model matches the filter conditions; False otherwise.
417444 :rtype: bool
445+ :raises ValueError: If an invalid operand is provided (not "and" or "or").
418446
419447
420448
421449 .. py :method :: _match_single_filter(model, attr, value)
422450
423- Check if a model matches a single attribute restriction.
451+ Check if a model matches a single attribute filter.
452+
453+ This method evaluates whether a model meets a single attribute restriction. It compares the model's attribute
454+ value to the provided filter value and returns a boolean indicating whether there is a match. It handles both
455+ single-value and list-value comparisons.
424456
425- :param model: The model to check .
457+ :param model: The model to be checked against the filter .
426458 :type model: Model
427- :param attr: The attribute name to filter by.
459+ :param attr: The name of the attribute to filter by.
428460 :type attr: str
429- :param value: The attribute value or list of values to filter by.
461+ :param value: The expected value or list of values to filter by.
430462 :type value: Any
431- :return: True if the model matches the restriction, False otherwise.
463+ :return: True if the model's attribute matches the filter; False otherwise.
432464 :rtype: bool
433465
434466
0 commit comments