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

Added option: EMMObased = False in ontology.load() #262

Merged
merged 12 commits into from
Oct 22, 2021
7 changes: 5 additions & 2 deletions ontopy/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def remove_label_annotation(self, iri):
def load(self, only_local=False, filename=None, format=None,
reload=None, reload_if_newer=False, url_from_catalog=None,
catalog_file='catalog-v001.xml', tmpdir=None,
**kwargs):
EMMObased=True, **kwargs):
CasperWA marked this conversation as resolved.
Show resolved Hide resolved
"""Load the ontology.

Parameters
Expand Down Expand Up @@ -314,6 +314,8 @@ def load(self, only_local=False, filename=None, format=None,
defaults to "catalog-v001.xml".
tmpdir : str
Path to temporary directory.
EMMObased : bool
francescalb marked this conversation as resolved.
Show resolved Hide resolved
Whether this is an EMMO-based ontology or not, default `True`.
kwargs
Additional keyword arguments are passed on to
owlready2.Ontology.load().
Expand All @@ -329,7 +331,7 @@ def load(self, only_local=False, filename=None, format=None,
tmpdir=tmpdir, **kwargs)

# Enable optimised search by get_by_label()
if self._special_labels is None:
if self._special_labels is None and EMMObased:
for iri in DEFAULT_LABEL_ANNOTATIONS:
self.add_label_annotation(iri)
t = self.world['http://www.w3.org/2002/07/owl#topObjectProperty']
Expand All @@ -347,6 +349,7 @@ def load(self, only_local=False, filename=None, format=None,
def _load(self, only_local=False, filename=None, format=None,
reload=None, reload_if_newer=False, url_from_catalog=None,
catalog_file='catalog-v001.xml', tmpdir=None,
EMMObased=True,
CasperWA marked this conversation as resolved.
Show resolved Hide resolved
**kwargs):
"""Help function for _load()."""
web_protocol = 'http://', 'https://', 'ftp://'
Expand Down
14 changes: 14 additions & 0 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ def test_load(repo_dir: "Path") -> None:
'https://raw.githubusercontent.com/BIG-MAP/BattINFO/master/'
'battinfo.ttl').load()
assert onto.Electrolyte.prefLabel.first() == 'Electrolyte'


def test_load_rdfs(repo_dir: "Path") -> None:
from ontopy import get_ontology

# Test loading non-EMMO-based ontologies rdf and rdfs
rdf_onto = get_ontology(
'https://www.w3.org/1999/02/22-rdf-syntax-ns.ttl').load(
EMMObased=False)
CasperWA marked this conversation as resolved.
Show resolved Hide resolved
rdfs_onto = get_ontology(
'https://www.w3.org/2000/01/rdf-schema.ttl').load(
EMMObased=False)
CasperWA marked this conversation as resolved.
Show resolved Hide resolved
rdfs_onto.Class # Needed to initialize rdfs_onto
assert type(rdf_onto.HTML).iri == rdfs_onto.Datatype.iri