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 function to load the emmo (the ontology) directly #226

Merged
merged 6 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions emmopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
# Ensure emmopy is imported before owlready2...
if 'owlready2' in sys.modules.keys() and "ontopy" not in sys.modules.keys():
raise RuntimeError('emmopy must be imported before owlready2')

# Import functions from emmopy
from .emmopy import get_emmo


__all__ = ("get_emmo",)
19 changes: 19 additions & 0 deletions emmopy/emmopy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from ontopy import get_ontology
from typing import Optional, TYPE_CHECKING

if TYPE_CHECKING:
from ontopy.ontology import Ontology


def get_emmo(inferred: Optional[bool] = True) -> "Ontology":
"""Returns the current version of emmo.

Args:
inferred: Whether to import the inferred version of emmo or not.
Default is True.

Returns:
The loaded emmo ontology.
"""
name = 'emmo-inferred' if inferred else 'emmo'
francescalb marked this conversation as resolved.
Show resolved Hide resolved
return get_ontology(name).load()
5 changes: 4 additions & 1 deletion tests/test_load_emmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ def test_load_emmo() -> None:
thisdir = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(1, os.path.abspath(os.path.join(thisdir, '..')))
from ontopy import get_ontology # noqa: E402, F401

from emmopy import get_emmo

emmo = get_ontology()
emmo.load()

EMMO_inferred = get_emmo()
EMMO = get_emmo(inferred=False)
francescalb marked this conversation as resolved.
Show resolved Hide resolved