-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathontology_import.py
More file actions
56 lines (48 loc) · 1.63 KB
/
Copy pathontology_import.py
File metadata and controls
56 lines (48 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
from osw.auth import CredentialManager
from osw.core import model
from osw.express import OswExpress
from osw.ontology import ImportConfig, OntologyImporter
# Use credentials from file. if none are found, the user will be prompted to enter them
cm = CredentialManager(
cred_filepath=os.path.join(
os.path.dirname(os.path.abspath(__file__)), "accounts.pwd.yaml"
)
)
# Create the OSW object
osw_obj = OswExpress(domain="wiki-dev.open-semantic-lab.org", cred_mngr=cm)
DEPENDENCIES = {
"OwlClass": "Category:OSW725a3cf5458f4daea86615fcbd0029f8",
"OwlIndividual": "Category:OSW6b9ef2784a934b8ab96523366e23e906",
"Item": "Category:Item",
"ObjectProperty": "Category:ObjectProperty",
"DataProperty": "Category:DataProperty",
"AnnotationProperty": "Category:AnnotationProperty",
}
osw_obj.install_dependencies(DEPENDENCIES, mode="append")
ontology_name = "example_ontology"
ex = model.OwlOntology(
name="Example",
label=[model.Label(text="Example", lang="en")],
iri="http://example.com",
prefix="http://example.com/",
prefix_name="example",
see_also=["http://example.com"],
)
import_config = ImportConfig(
ontology_name=ontology_name,
ontologies=[ex],
file=os.path.join(
os.path.dirname(os.path.abspath(__file__)), "data", f"{ontology_name}.ttl"
),
base_class=model.OwlClass,
base_class_title="Category:OSW725a3cf5458f4daea86615fcbd0029f8", # OwlClass
dump_files=True,
dump_path=os.path.dirname(os.path.abspath(__file__)),
dry_run=False,
)
# Import ontologies
importer = OntologyImporter(
osw=osw_obj,
)
importer.import_ontology(import_config)