Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to owlready0.45 #717

Closed
wants to merge 12 commits into from
Closed
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
11 changes: 5 additions & 6 deletions ontopy/excelparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,14 @@ def get_metadata_from_dataframe( # pylint: disable=too-many-locals,too-many-bra

# Add versionInfo
try:
_add_literal(
metadata,
onto.metadata.versionInfo,
"Ontology version Info",
metadata=True,
only_one=True,
name_list = _parse_literal(
metadata, "Ontology version Info", metadata=True
)
onto.metadata.versionInfo.append(name_list[0])
except AttributeError:
pass

onto.set_version(onto.get_version())
return onto, catalog


Expand Down
36 changes: 35 additions & 1 deletion ontopy/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_ontology(
version of EMMO. Until first stable release
emmo-inferred and emmo-development will be the same.
OntologyClass: If given and `base_iri` doesn't correspond
to an existing ontology, a new ontology is created of
an existing ontology, a new ontology is created of
this Ontology subclass. Defaults to `ontopy.Ontology`.
label_annotations: Sequence of label IRIs used for accessing
entities in the ontology given that they are in the ontology.
Expand Down Expand Up @@ -875,6 +875,7 @@ def save(
write_catalog_file=False,
append_catalog=False,
catalog_file="catalog-v001.xml",
keep_python_names=False,
**kwargs,
) -> Path:
"""Writes the ontology to file.
Expand Down Expand Up @@ -937,6 +938,29 @@ def save(
"'Known issues' section of the README."
)
)
if not keep_python_names:
ontocopy = self.copy()
ontocopy._del_data_triple_spod(
p=ontocopy._abbreviate(
"http://www.lesfleursdunormal.fr/static/_downloads/"
"owlready_ontology.owl#python_name"
)
)
returnpath = ontocopy.save(
filename=filename,
format=format,
dir=dir,
mkdir=mkdir,
overwrite=overwrite,
recursive=recursive,
squash=squash,
write_catalog_file=write_catalog_file,
append_catalog=append_catalog,
catalog_file=catalog_file,
keep_python_names=True,
)
return returnpath

revmap = {value: key for key, value in FMAP.items()}
if filename is None:
if format:
Expand Down Expand Up @@ -988,6 +1012,7 @@ def save(
recursive=False,
squash=False,
write_catalog_file=False,
keep_python_names=keep_python_names,
**kwargs,
)

Expand Down Expand Up @@ -1104,9 +1129,18 @@ def copy(self):
recursive=True,
write_catalog_file=True,
mkdir=True,
keep_python_names=True,
)
# copy all in dirname to new directory
# newdir = Path("/home/flb/projects/Team4.0/EMMOntoPy/temp/newonto")
# import shutil

# shutil.copytree(dirname, newdir)
# print(filename)
ontology = get_ontology(filename).load()
ontology.name = self.name
ontology.iri = self.iri
ontology.base_iri = self.base_iri
return ontology

def get_imported_ontologies(self, recursive=False):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_excelparser/result_ontology/fromexcelonto.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://emmo.info/emmo/domain/onto> a owl:Ontology ;
dcterms:contributor "SINTEF"@en,
Expand All @@ -14,7 +15,8 @@
dcterms:title "A test domain ontology"@en ;
owl:imports <http://emmo.info/emmo>,
<http://ontology.info/ontology> ;
owl:versionInfo "0.01"@en .
owl:versionIRI <http://emmo.info/emmo/domain/0.01/onto> ;
owl:versionInfo "0.01"^^xsd:string .

:EMMO_0264be35-e8ad-5b35-a1a3-84b37bde22d1 a owl:Class ;
emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "Temporal pattern occurring in a time interval"@en ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://emmo.info/emmo/domain/onto> a owl:Ontology ;
dcterms:contributor "SINTEF"@en,
Expand All @@ -14,7 +15,8 @@
dcterms:title "A test domain ontology"@en ;
owl:imports <http://emmo.info/emmo>,
<http://ontology.info/ontology> ;
owl:versionInfo "0.01"@en .
owl:versionIRI <http://emmo.info/emmo/domain/0.01/onto> ;
owl:versionInfo "0.01"^^xsd:string .

:EMMO_0264be35-e8ad-5b35-a1a3-84b37bde22d1 a owl:Class ;
emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "Temporal pattern occurring in a time interval"@en ;
Expand Down
13 changes: 12 additions & 1 deletion tests/test_excelparser/test_excelparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ def test_excelparser(repo_dir: "Path") -> None:
repo_dir / "tests" / "test_excelparser" / "onto_update.xlsx"
)
ontology, catalog, errors = create_ontology_from_excel(xlspath, force=True)
# ontology.save("test.ttl") # used for printing new ontology when debugging
# ontology.save("test.ttl", keep_python_names=False) # used for printing new ontology when debugging
ontology._del_data_triple_spod(
p=ontology._abbreviate(
"http://www.lesfleursdunormal.fr/static/_downloads/"
"owlready_ontology.owl#python_name"
)
)

ontology.save(
"test.ttl", keep_python_names=True
) # used for printing new ontology when debugging

assert onto == ontology
assert errors.keys() == {
"already_defined",
Expand Down
Loading