-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_upd_onto.py
62 lines (31 loc) · 1.2 KB
/
test_upd_onto.py
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
# test_upd_onto.py
from upd_onto import *
import shutil
# c:\D\Нинь\учёба\09s\reasoning\onto-work\c_owl\upd-ontology-test.rdf
# onto_path.append(r"c:\D\Нинь\учёба\09s\reasoning\onto-work\c_owl")
onto_path.append(r"onto")
onto_path.append(r"c:\D\Нинь\Dev\ML_exp\owlready\onto")
# Пути неверные! См. ipynb в \Dev\ML_exp\owlready\TestUpdOnto.ipynb
ontology_path = "onto/upd-ontology-test.rdf"
ontology_file = "upd-ontology-test.rdf"
onto = get_ontology(ontology_file)
onto.load()
list(onto.individuals())
wr_onto = AugmentingOntology(onto, no_init=1)
wr_onto.init(verbose=1)
with onto:
r = """
Referenceable(?x), Referenceable(?y), DifferentFrom(?x, ?y) -> UNLINK_friend(?x, ?y)
"""
Imp().set_as_rule(r)
with onto:
r = """
Referenceable(?x), IRI(?x, "d") -> DESTROY_INSTANCE(?x), CREATE(INSTANCE , "Referenceable{neighbour=a; friend=b}")
"""
Imp().set_as_rule(r)
list(onto.individuals())
wr_onto.sync()
shutil.copyfile(ontology_path, ontology_path.replace(".", "_backup."))
ontology_file2 = ontology_path.replace(".", "_ext.")
onto.save(file=ontology_file2, format='rdfxml')
print("Saved RDF file: {} !".format(ontology_file2))