Skip to content

Commit

Permalink
docstring added
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirrr committed Nov 8, 2024
1 parent 60e113f commit 3f6d288
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions owlapy/util_owl_static_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,32 @@ def save_owl_class_expressions(expressions: OWLClassExpression | List[OWLClassEx
rdf_format: str = 'rdfxml',
namespace:str=None) -> None:
"""
Saves a set of OWL class expressions to an ontology file in RDF/XML format.
"""
This function takes one or more OWL class expressions, creates an ontology,
and saves the expressions as OWL equivalent class axioms in the specified RDF format.
By default, it saves the file to the specified path using the 'rdfxml' format.
Args:
expressions (OWLClassExpression | List[OWLClassExpression]): A single or a list of OWL class expressions
to be saved as equivalent class axioms.
path (str, optional): The file path where the ontology will be saved. Defaults to 'predictions'.
rdf_format (str, optional): RDF serialization format for saving the ontology. Currently only
supports 'rdfxml'. Defaults to 'rdfxml'.
namespace (str, optional): The namespace URI used for the ontology. If None, defaults to
'https://dice-research.org/predictions#'. Must end with '#'.
Raises:
AssertionError: If `expressions` is neither an OWLClassExpression nor a list of OWLClassExpression.
AssertionError: If `rdf_format` is not 'rdfxml'.
AssertionError: If `namespace` does not end with a '#'.
Example:
>>> from some_module import OWLClassExpression
>>> expr1 = OWLClassExpression("SomeExpression1")
>>> expr2 = OWLClassExpression("SomeExpression2")
>>> save_owl_class_expressions([expr1, expr2], path="my_ontology.owl", rdf_format="rdfxml")
"""
assert isinstance(expressions, OWLClassExpression) or isinstance(expressions[0],
OWLClassExpression), "expressions must be either OWLClassExpression or a list of OWLClassExpression"
assert rdf_format == 'rdfxml', f'Format {rdf_format} not implemented. Please use rdfxml'
Expand Down Expand Up @@ -40,7 +63,4 @@ def save_owl_class_expressions(expressions: OWLClassExpression | List[OWLClassEx
print(i)
print(expressions)
exit(1)
print(ontology)
ontology.save(path=path, inplace=False, rdf_format=rdf_format)

# ontology.save(IRI.create(path))
ontology.save(path=path, inplace=False, rdf_format=rdf_format)

0 comments on commit 3f6d288

Please sign in to comment.