ontoripple 0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ontoripple/__init__.py +142 -0
- ontoripple/__main__.py +94 -0
- ontoripple/constants.py +265 -0
- ontoripple/evol_kg.py +1956 -0
- ontoripple-0.1.dist-info/LICENSE +201 -0
- ontoripple-0.1.dist-info/METADATA +57 -0
- ontoripple-0.1.dist-info/RECORD +8 -0
- ontoripple-0.1.dist-info/WHEEL +4 -0
ontoripple/__init__.py
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
from rdflib import URIRef, Graph
|
2
|
+
from .constants import *
|
3
|
+
from .evol_kg import *
|
4
|
+
|
5
|
+
def propagate(change_data, output_mappings, review_mappings, ontology, output_shacl):
|
6
|
+
changes_order = (
|
7
|
+
OCH_REVOKE_DEPRECATE,
|
8
|
+
OCH_REMOVE_INVERSE_PROPERTY,
|
9
|
+
OCH_REMOVE_DISJOINT_PROPERTY,
|
10
|
+
OCH_REMOVE_EQUIVALENT_PROPERTY,
|
11
|
+
OCH_REMOVE_SUBPROPERTY,
|
12
|
+
OCH_REMOVE_CHARACTERISTIC,
|
13
|
+
OCH_REMOVE_DISJOINT_CLASS,
|
14
|
+
OCH_REMOVE_EQUIVALENT_CLASS,
|
15
|
+
OCH_REMOVE_SUBCLASS,
|
16
|
+
OCH_REMOVE_DOMAIN,
|
17
|
+
OCH_REMOVE_RANGE_OBJECT,
|
18
|
+
OCH_REMOVE_DATA_PROPERTY,
|
19
|
+
OCH_REMOVE_OBJECT_PROPERTY,
|
20
|
+
OCH_REMOVE_CLASS,
|
21
|
+
OCH_ADD_CLASS,
|
22
|
+
OCH_ADD_OBJECT_PROPERTY,
|
23
|
+
OCH_ADD_DATA_PROPERTY,
|
24
|
+
OCH_ADD_DOMAIN,
|
25
|
+
OCH_ADD_RANGE_OBJECT,
|
26
|
+
OCH_ADD_SUBCLASS,
|
27
|
+
OCH_ADD_SUBPROPERTY,
|
28
|
+
OCH_ADD_EQUIVALENT_CLASS,
|
29
|
+
OCH_ADD_EQUIVALENT_PROPERTY,
|
30
|
+
OCH_ADD_DISJOINT_CLASS,
|
31
|
+
OCH_ADD_DISJOINT_PROPERTY,
|
32
|
+
OCH_ADD_INVERSE_PROPERTY,
|
33
|
+
OCH_ADD_CHARACTERISTIC,
|
34
|
+
OCH_RENAME_ENTITY,
|
35
|
+
OCH_DEPRECATE_ENTITY )
|
36
|
+
|
37
|
+
for change_type in changes_order:
|
38
|
+
|
39
|
+
q = f' SELECT DISTINCT ?change WHERE {{ ' \
|
40
|
+
f' ?change {RDF_TYPE} {URIRef(change_type)} . }}'
|
41
|
+
#print(q)
|
42
|
+
for change_result in change_data.query(q):
|
43
|
+
if URIRef(change_type) == URIRef(OCH_ADD_CLASS):
|
44
|
+
if output_mappings is not None:
|
45
|
+
add_class_rml(change_result["change"], change_data, output_mappings)
|
46
|
+
if output_shacl is not None:
|
47
|
+
add_class_shacl(change_result["change"], change_data,output_shacl)
|
48
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_CLASS):
|
49
|
+
if output_mappings is not None:
|
50
|
+
remove_class_rml(change_result["change"], change_data, output_mappings, review_mappings, ontology)
|
51
|
+
if output_shacl is not None:
|
52
|
+
remove_class_shacl(change_result["change"], change_data, output_shacl)
|
53
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_SUBCLASS):
|
54
|
+
if output_mappings is not None:
|
55
|
+
add_super_class_rml(change_result["change"], change_data, output_mappings)
|
56
|
+
if output_shacl is not None:
|
57
|
+
add_super_class_shacl(change_result["change"], change_data, output_shacl)
|
58
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_SUBCLASS):
|
59
|
+
if output_mappings is not None:
|
60
|
+
remove_super_class_rml(change_result["change"], change_data, output_mappings)
|
61
|
+
if output_shacl is not None:
|
62
|
+
remove_super_class_shacl(change_result["change"], change_data, output_shacl)
|
63
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_OBJECT_PROPERTY):
|
64
|
+
if output_mappings is not None:
|
65
|
+
add_object_property_rml(change_result["change"], change_data, output_mappings)
|
66
|
+
if output_shacl is not None:
|
67
|
+
add_object_property_shacl(change_result["change"], change_data, output_shacl)
|
68
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_OBJECT_PROPERTY):
|
69
|
+
if output_mappings is not None:
|
70
|
+
remove_object_property_rml(change_result["change"], change_data, output_mappings)
|
71
|
+
if output_shacl is not None:
|
72
|
+
remove_object_property_shacl(change_result["change"], change_data, output_shacl)
|
73
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_DATA_PROPERTY):
|
74
|
+
if output_mappings is not None:
|
75
|
+
add_data_property_rml(change_result["change"], change_data, output_mappings)
|
76
|
+
if output_shacl is not None:
|
77
|
+
add_data_property_shacl(change_result["change"], change_data, output_shacl)
|
78
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_DATA_PROPERTY):
|
79
|
+
if output_mappings is not None:
|
80
|
+
remove_data_property_rml(change_result["change"], change_data, output_mappings)
|
81
|
+
if output_shacl is not None:
|
82
|
+
remove_data_property_shacl(change_result["change"], change_data, output_shacl)
|
83
|
+
elif URIRef(change_type) == URIRef(OCH_DEPRECATE_ENTITY):
|
84
|
+
if output_mappings is not None:
|
85
|
+
deprecate_entity_rml(change_result["change"], change_data, output_mappings, review_mappings, ontology)
|
86
|
+
if output_shacl is not None:
|
87
|
+
deprecate_entity_shacl(change_result["change"], change_data, output_shacl)
|
88
|
+
elif URIRef(change_type) == URIRef(OCH_REVOKE_DEPRECATE):
|
89
|
+
if output_mappings is not None:
|
90
|
+
revoke_deprecate_entity_rml(change_result["change"], change_data, output_mappings, review_mappings, ontology)
|
91
|
+
if output_shacl is not None:
|
92
|
+
revoke_deprecate_entity_shacl(change_result["change"], change_data, output_shacl)
|
93
|
+
elif URIRef(change_type) == URIRef(OCH_RENAME_ENTITY):
|
94
|
+
if output_mappings is not None:
|
95
|
+
rename_entity(change_result["change"], change_data, output_mappings)
|
96
|
+
if output_shacl is not None:
|
97
|
+
rename_entity(change_result["change"], change_data, output_shacl)
|
98
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_EQUIVALENT_CLASS):
|
99
|
+
if output_shacl is not None:
|
100
|
+
add_equivalent_class_shacl(change_result["change"], change_data, output_shacl)
|
101
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_EQUIVALENT_CLASS):
|
102
|
+
if output_shacl is not None:
|
103
|
+
remove_equivalent_class_shacl(change_result["change"], change_data, output_shacl)
|
104
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_DISJOINT_CLASS):
|
105
|
+
if output_shacl is not None:
|
106
|
+
add_disjoint_class_shacl(change_result["change"], change_data, output_shacl)
|
107
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_DISJOINT_CLASS):
|
108
|
+
if output_shacl is not None:
|
109
|
+
remove_disjoint_class_shacl(change_result["change"], change_data, output_shacl)
|
110
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_CHARACTERISTIC):
|
111
|
+
if output_shacl is not None:
|
112
|
+
add_characteristic_shacl(change_result["change"], change_data, output_shacl)
|
113
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_CHARACTERISTIC):
|
114
|
+
if output_shacl is not None:
|
115
|
+
remove_characteristic_shacl(change_result["change"], change_data, output_shacl)
|
116
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_INVERSE_PROPERTY):
|
117
|
+
if output_shacl is not None:
|
118
|
+
add_inverse_property_shacl(change_result["change"], change_data, output_shacl)
|
119
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_INVERSE_PROPERTY):
|
120
|
+
if output_shacl is not None:
|
121
|
+
remove_inverse_property_shacl(change_result["change"], change_data, output_shacl)
|
122
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_DISJOINT_PROPERTY):
|
123
|
+
if output_shacl is not None:
|
124
|
+
add_disjoint_property_shacl(change_result["change"], change_data, output_shacl)
|
125
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_DISJOINT_PROPERTY):
|
126
|
+
if output_shacl is not None:
|
127
|
+
remove_disjoint_property_shacl(change_result["change"], change_data, output_shacl)
|
128
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_SUBPROPERTY):
|
129
|
+
if output_shacl is not None:
|
130
|
+
add_superproperty_shacl(change_result["change"], change_data, output_shacl)
|
131
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_SUBPROPERTY):
|
132
|
+
if output_shacl is not None:
|
133
|
+
remove_superproperty_shacl(change_result["change"], change_data, output_shacl)
|
134
|
+
elif URIRef(change_type) == URIRef(OCH_ADD_EQUIVALENT_PROPERTY):
|
135
|
+
if output_shacl is not None:
|
136
|
+
add_equivalent_property_shacl(change_result["change"], change_data, output_shacl)
|
137
|
+
elif URIRef(change_type) == URIRef(OCH_REMOVE_EQUIVALENT_PROPERTY):
|
138
|
+
if output_shacl is not None:
|
139
|
+
remove_equivalent_property_shacl(change_result["change"], change_data, output_shacl)
|
140
|
+
|
141
|
+
logger.info("Changes propagated over semantic artefacts, writing results...")
|
142
|
+
return output_mappings, output_shacl
|
ontoripple/__main__.py
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
from rdflib import Graph, URIRef, Variable
|
3
|
+
from . import propagate
|
4
|
+
import yatter
|
5
|
+
import argparse
|
6
|
+
from ruamel.yaml import YAML
|
7
|
+
from .evol_kg import *
|
8
|
+
|
9
|
+
def define_args():
|
10
|
+
parser = argparse.ArgumentParser()
|
11
|
+
parser.add_argument("-c", "--changes_kg_path", required=True, help="Change KG following the Change Ontology")
|
12
|
+
parser.add_argument("-m", "--old_mapping_path", required=False, help="Old version of the mappings in RML")
|
13
|
+
parser.add_argument("-s", "--old_shacl_path", required=False, help="Old version of the shapes in SHACL")
|
14
|
+
parser.add_argument("-o", "--ontology_path", required=False, help="New version of the ontology")
|
15
|
+
parser.add_argument("-nm", "--new_mappings_path", required=False, help="Output path for the generated mapping")
|
16
|
+
parser.add_argument("-nsh", "--new_shapes_path", required=False, help="Output path for the generated shapes")
|
17
|
+
parser.add_argument("-y", "--yarrrml", nargs=argparse.OPTIONAL, required=False, help="Mappings are also converted into YARRRML")
|
18
|
+
return parser
|
19
|
+
|
20
|
+
|
21
|
+
if __name__ == "__main__":
|
22
|
+
args = define_args().parse_args()
|
23
|
+
change_data = Graph().parse(args.changes_kg_path, format="ttl")
|
24
|
+
|
25
|
+
# Case 1: Both mapping and SHACL parameters are provided
|
26
|
+
if (
|
27
|
+
args.old_mapping_path and args.new_mappings_path and
|
28
|
+
args.old_shacl_path and args.new_shapes_path
|
29
|
+
):
|
30
|
+
# Process mappings
|
31
|
+
if args.old_mapping_path.endswith(".yml") or args.old_mapping_path.endswith(".yaml"):
|
32
|
+
logger.info("Starting the propagation of changes over the mapping rules")
|
33
|
+
logger.info("Loading old mapping rules from YARRRML using YATTER")
|
34
|
+
yaml = YAML(typ='safe', pure=True)
|
35
|
+
output_mappings = Graph().parse(
|
36
|
+
yatter.translate(yaml.load(open(args.old_mapping_path)), RML_URI), format="ttl"
|
37
|
+
)
|
38
|
+
else:
|
39
|
+
output_mappings = Graph().parse(args.old_mapping_path, format="ttl")
|
40
|
+
ontology = None
|
41
|
+
if args.ontology_path:
|
42
|
+
ontology = Graph().parse(args.ontology_path)
|
43
|
+
|
44
|
+
logger.info("Starting the propagation of changes over RML mappings and SHACL shapes")
|
45
|
+
review_mappings = Graph()
|
46
|
+
output_shapes = Graph().parse(args.old_shacl_path, format="ttl")
|
47
|
+
|
48
|
+
new_mapping,new_shapes = propagate(change_data, output_mappings, review_mappings, ontology, output_shapes)
|
49
|
+
new_mapping.serialize(destination=args.new_mappings_path)
|
50
|
+
new_shapes.serialize(destination=args.new_shapes_path)
|
51
|
+
review_mappings.serialize(destination="review_mappings.ttl")
|
52
|
+
yarrrml_content = yatter.inverse_translation(output_mappings)
|
53
|
+
with open(args.new_mappings_path.replace(".ttl", ".yml"), "wb") as f:
|
54
|
+
yaml = YAML()
|
55
|
+
yaml.default_flow_style = False
|
56
|
+
yaml.width = 3000
|
57
|
+
yaml.dump(yarrrml_content, f)
|
58
|
+
|
59
|
+
# Case 2: Only mapping parameters are provided
|
60
|
+
elif args.old_mapping_path and args.new_mappings_path:
|
61
|
+
if args.old_mapping_path.endswith(".yml") or args.old_mapping_path.endswith(".yaml"):
|
62
|
+
logger.info("Starting the propagation of changes over the mapping rules")
|
63
|
+
logger.info("Loading old mapping rules from YARRRML using YATTER")
|
64
|
+
yaml = YAML(typ='safe', pure=True)
|
65
|
+
output_mappings = Graph().parse(
|
66
|
+
yatter.translate(yaml.load(open(args.old_mapping_path)), RML_URI), format="ttl"
|
67
|
+
)
|
68
|
+
else:
|
69
|
+
output_mappings = Graph().parse(args.old_mapping_path, format="ttl")
|
70
|
+
|
71
|
+
ontology = None
|
72
|
+
if args.ontology_path:
|
73
|
+
ontology = Graph().parse(args.ontology_path)
|
74
|
+
|
75
|
+
review_mappings = Graph()
|
76
|
+
new_mapping,new_shapes = propagate(change_data, output_mappings, review_mappings, ontology, None)
|
77
|
+
new_mapping.serialize(destination=args.new_mappings_path)
|
78
|
+
review_mappings.serialize(destination="review_mappings.ttl")
|
79
|
+
yarrrml_content = yatter.inverse_translation(output_mappings)
|
80
|
+
with open(args.new_mappings_path.replace(".ttl", ".yml"), "wb") as f:
|
81
|
+
yaml = YAML()
|
82
|
+
yaml.default_flow_style = False
|
83
|
+
yaml.width = 3000
|
84
|
+
yaml.dump(yarrrml_content, f)
|
85
|
+
|
86
|
+
# Case 3: Only SHACL parameters are provided
|
87
|
+
elif args.old_shacl_path and args.new_shapes_path:
|
88
|
+
logger.info("Starting the propagation of changes over the SHACL shapes")
|
89
|
+
output_shapes = Graph().parse(args.old_shacl_path, format="ttl")
|
90
|
+
ontology = None
|
91
|
+
if args.ontology_path:
|
92
|
+
ontology = Graph().parse(args.ontology_path)
|
93
|
+
new_mapping,new_shapes = propagate(change_data, None, None, ontology, output_shapes)
|
94
|
+
new_shapes.serialize(destination=args.new_shapes_path)
|
ontoripple/constants.py
ADDED
@@ -0,0 +1,265 @@
|
|
1
|
+
import logging, coloredlogs
|
2
|
+
|
3
|
+
##############################################################################
|
4
|
+
############################# RML CONSTANTS ###############################
|
5
|
+
##############################################################################
|
6
|
+
|
7
|
+
RML_URI = 'http://semweb.mmlab.be/ns/rml#'
|
8
|
+
R2RML_URI = 'http://www.w3.org/ns/r2rml#'
|
9
|
+
RDF_URI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
|
10
|
+
D2RQ_URI = 'http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#'
|
11
|
+
QL_URI = 'http://semweb.mmlab.be/ns/ql#'
|
12
|
+
EXAMPLE_PREFIX = 'ex'
|
13
|
+
EXAMPLE_URI = "http://myexampleuri.org/data#"
|
14
|
+
RDFS_URI = 'http://www.w3.org/2000/01/rdf-schema#'
|
15
|
+
XSD_URI = 'http://www.w3.org/2001/XMLSchema#'
|
16
|
+
FOAF_URI = 'http://xmlns.com/foaf/0.1/'
|
17
|
+
RDF_TYPE = 'rdf:type'
|
18
|
+
SCHEMA_URI = 'http://schema.org/'
|
19
|
+
STAR_URI = 'https://w3id.org/kg-construct/rml-star'
|
20
|
+
COMPRESSION_URI = 'http://semweb.mmlab.be/ns/rml-compression#'
|
21
|
+
FORMATS_URI = 'http://www.w3.org/ns/formats/'
|
22
|
+
VOID_URI = 'http://rdfs.org/ns/void#'
|
23
|
+
FNML_URI = 'http://semweb.mmlab.be/ns/fnml#'
|
24
|
+
GREL_URI = 'http://users.ugent.be/~bjdmeest/function/grel.ttl#'
|
25
|
+
OCH_URI = 'https://w3id.org/def/och#'
|
26
|
+
|
27
|
+
R2RML_PREFIX = 'rr'
|
28
|
+
RML_PREFIX = 'rml'
|
29
|
+
OCH_PREFIX = 'och'
|
30
|
+
RDF_PREFIX = 'rdf'
|
31
|
+
RDFS_PREFIX = 'rdfs'
|
32
|
+
RDF_FIRST = f'{RDF_PREFIX}:first'
|
33
|
+
RDF_REST = f'{RDF_PREFIX}:rest'
|
34
|
+
RDF_TYPE = f'{RDF_PREFIX}:type'
|
35
|
+
TURTLE_PREFIX = '@prefix'
|
36
|
+
RML_BASE = '@base'
|
37
|
+
RML_LOGICAL_SOURCE_CLASS = f'{RML_PREFIX}:LogicalSource'
|
38
|
+
RML_LOGICAL_SOURCE = f'{RML_PREFIX}:logicalSource'
|
39
|
+
RML_SOURCE = f'{RML_PREFIX}:source'
|
40
|
+
RML_REFERENCE_FORMULATION = f'{RML_PREFIX}:referenceFormulation'
|
41
|
+
RML_ITERATOR = f'{RML_PREFIX}:iterator'
|
42
|
+
RML_REFERENCE = f'{RML_PREFIX}:reference'
|
43
|
+
RML_LANGUAGE_MAP = f'{RML_PREFIX}:languageMap'
|
44
|
+
RML_LANGUAGE_MAP_CLASS = f'{RML_PREFIX}:LanguageMap'
|
45
|
+
RML_DATATYPE_MAP = f'{RML_PREFIX}:datatypeMap'
|
46
|
+
RML_DATATYPE_MAP_CLASS = f'{RML_PREFIX}:DatatypeMap'
|
47
|
+
RML_QUERY = f'{RML_PREFIX}:query'
|
48
|
+
|
49
|
+
RML_LOGICAL_TARGET = f'{RML_PREFIX}:logicalTarget'
|
50
|
+
RML_LOGICAL_TARGET_CLASS = f'{RML_PREFIX}:LogicalTarget'
|
51
|
+
RML_TARGET = f'{RML_PREFIX}:target'
|
52
|
+
RML_SERIALIZATION = f'{RML_PREFIX}:serialization'
|
53
|
+
RML_COMPRESSION = f'{RML_PREFIX}:compression'
|
54
|
+
|
55
|
+
R2RML_TEMPLATE = f'{R2RML_PREFIX}:template'
|
56
|
+
R2RML_TRIPLES_MAP = f'{R2RML_PREFIX}:TriplesMap'
|
57
|
+
R2RML_CONSTANT = f'{R2RML_PREFIX}:constant'
|
58
|
+
R2RML_SUBJECT = f'{R2RML_PREFIX}:subjectMap'
|
59
|
+
R2RML_SUBJECT_CLASS = f'{R2RML_PREFIX}:SubjectMap'
|
60
|
+
R2RML_CLASS = f'{R2RML_PREFIX}:class'
|
61
|
+
R2RML_SQL_VERSION = f'{R2RML_PREFIX}:sqlVersion'
|
62
|
+
R2RML_SQL_QUERY = f'{R2RML_PREFIX}:sqlQuery'
|
63
|
+
R2RML_PREDICATE_OBJECT_MAP = f'{R2RML_PREFIX}:predicateObjectMap'
|
64
|
+
R2RML_PREDICATE_OBJECT_MAP_CLASS = f'{R2RML_PREFIX}:PredicateObjectMap'
|
65
|
+
R2RML_SHORTCUT_PREDICATE = f'{R2RML_PREFIX}:predicate'
|
66
|
+
R2RML_PREDICATE = f'{R2RML_PREFIX}:predicateMap'
|
67
|
+
R2RML_PREDICATE_CLASS = f'{R2RML_PREFIX}:PredicateMap'
|
68
|
+
R2RML_SHORTCUT_OBJECT = f'{R2RML_PREFIX}:object'
|
69
|
+
R2RML_OBJECT = f'{R2RML_PREFIX}:objectMap'
|
70
|
+
R2RML_OBJECT_CLASS = f'{R2RML_PREFIX}:ObjectMap'
|
71
|
+
R2RML_GRAPH = f'{R2RML_PREFIX}:graph'
|
72
|
+
R2RML_GRAPH_MAP = f'{R2RML_PREFIX}:graphMap'
|
73
|
+
R2RML_GRAPH_CLASS = f'{R2RML_PREFIX}:GraphMap'
|
74
|
+
R2RML_DATATYPE = f'{R2RML_PREFIX}:datatype'
|
75
|
+
R2RML_TERMTYPE = f'{R2RML_PREFIX}:termType'
|
76
|
+
R2RML_LANGUAGE = f'{R2RML_PREFIX}:language'
|
77
|
+
R2RML_IRI = f'{R2RML_PREFIX}:IRI'
|
78
|
+
R2RML_BLANK_NODE = f'{R2RML_PREFIX}:BlankNode'
|
79
|
+
R2RML_LITERAL = f'{R2RML_PREFIX}:Literal'
|
80
|
+
R2RML_REFOBJECT_CLASS = f'{R2RML_PREFIX}:RefObjectMap'
|
81
|
+
R2RML_PARENT_TRIPLESMAP = f'{R2RML_PREFIX}:parentTriplesMap'
|
82
|
+
R2RML_JOIN_CONDITION = f'{R2RML_PREFIX}:joinCondition'
|
83
|
+
R2RML_CHILD = f'{R2RML_PREFIX}:child'
|
84
|
+
R2RML_PARENT = f'{R2RML_PREFIX}:parent'
|
85
|
+
R2RML_LOGICAL_TABLE_CLASS = f'{R2RML_PREFIX}:LogicalTable'
|
86
|
+
R2RML_LOGICAL_TABLE = f'{R2RML_PREFIX}:logicalTable'
|
87
|
+
R2RML_TABLE_NAME = f'{R2RML_PREFIX}:tableName'
|
88
|
+
R2RML_COLUMN = f'{R2RML_PREFIX}:column'
|
89
|
+
|
90
|
+
##############################################################################
|
91
|
+
############################# SHACL CONSTANTS ###############################
|
92
|
+
##############################################################################
|
93
|
+
SHACL_URI = 'http://www.w3.org/ns/shacl#'
|
94
|
+
SHACL_PREFIX = 'sh'
|
95
|
+
SHACL_SHAPE = f'{SHACL_PREFIX}:Shape'
|
96
|
+
SHACL_NODE_SHAPE = f'{SHACL_PREFIX}:NodeShape'
|
97
|
+
SHACL_PROPERTY_SHAPE = f'{SHACL_PREFIX}:PropertyShape'
|
98
|
+
SHACL_TARGET_CLASS = f'{SHACL_PREFIX}:targetClass'
|
99
|
+
SHACL_DEACTIVATED = f'{SHACL_PREFIX}:deactivated'
|
100
|
+
SHACL_PATH = f'{SHACL_PREFIX}:path'
|
101
|
+
SHACL_IN = f'{SHACL_PREFIX}:in'
|
102
|
+
SHACL_OR = f'{SHACL_PREFIX}:or'
|
103
|
+
SHACL_AND = f'{SHACL_PREFIX}:and'
|
104
|
+
SHACL_XONE = f'{SHACL_PREFIX}:xone'
|
105
|
+
SHACL_SPARQL = f'{SHACL_PREFIX}:sparql'
|
106
|
+
SHACL_SPARQL_CONSTRAINT = f'{SHACL_PREFIX}:SPARQLConstraint'
|
107
|
+
SHACL_SPARQL_SELECT = f'{SHACL_PREFIX}:select'
|
108
|
+
SHACL_CLASS = f'{SHACL_PREFIX}:class'
|
109
|
+
SHACL_PROPERTY = f'{SHACL_PREFIX}:property'
|
110
|
+
SHACL_DATATYPE = f'{SHACL_PREFIX}:datatype'
|
111
|
+
SHACL_NOT = f'{SHACL_PREFIX}:not'
|
112
|
+
SHACL_MAX_COUNT = f'{SHACL_PREFIX}:maxCount'
|
113
|
+
SHACL_INVERSE_PATH = f'{SHACL_PREFIX}:inversePath'
|
114
|
+
SHACL_DISJOINT = f'{SHACL_PREFIX}:disjoint'
|
115
|
+
SHACL_EQUALS = f'{SHACL_PREFIX}:equals'
|
116
|
+
|
117
|
+
##############################################################################
|
118
|
+
############################# D2RQ CONSTANTS ##############################
|
119
|
+
##############################################################################
|
120
|
+
D2RQ_DATABASE_CLASS = 'd2rq:Database'
|
121
|
+
D2RQ_DSN = 'd2rq:jdbcDSN'
|
122
|
+
D2RQ_DRIVER = 'd2rq:jdbcDriver'
|
123
|
+
D2RQ_USER = 'd2rq:username'
|
124
|
+
D2RQ_PASS = 'd2rq:password'
|
125
|
+
|
126
|
+
##############################################################################
|
127
|
+
############################# OCH CONSTANTS ###############################
|
128
|
+
##############################################################################
|
129
|
+
|
130
|
+
OCH_ADD_CLASS = f'{OCH_PREFIX}:AddClass'
|
131
|
+
OCH_REMOVE_CLASS = f'{OCH_PREFIX}:RemoveClass'
|
132
|
+
OCH_ADD_SUBCLASS = f'{OCH_PREFIX}:AddSubClass'
|
133
|
+
OCH_REMOVE_SUBCLASS = f'{OCH_PREFIX}:RemoveSubClass'
|
134
|
+
OCH_ADD_OBJECT_PROPERTY = f'{OCH_PREFIX}:AddObjectProperty'
|
135
|
+
OCH_REMOVE_OBJECT_PROPERTY = f'{OCH_PREFIX}:RemoveObjectProperty'
|
136
|
+
OCH_ADD_DATA_PROPERTY = f'{OCH_PREFIX}:AddDataProperty'
|
137
|
+
OCH_REMOVE_DATA_PROPERTY = f'{OCH_PREFIX}:RemoveDataProperty'
|
138
|
+
OCH_ADD_DOMAIN = f'{OCH_PREFIX}:AddDomain'
|
139
|
+
OCH_REMOVE_DOMAIN = f'{OCH_PREFIX}:RemoveDomain'
|
140
|
+
OCH_ADD_RANGE_OBJECT = f'{OCH_PREFIX}:AddRangeObjectProperty'
|
141
|
+
OCH_REMOVE_RANGE_OBJECT = f'{OCH_PREFIX}:RemoveRangeObjectProperty'
|
142
|
+
OCH_ADD_RANGE_DATA = f'{OCH_PREFIX}:AddRangeDataProperty'
|
143
|
+
OCH_REMOVE_RANGE_DATA = f'{OCH_PREFIX}:RemoveRangeDataProperty'
|
144
|
+
OCH_DEPRECATE_ENTITY = f'{OCH_PREFIX}:DeprecateEntity'
|
145
|
+
OCH_REVOKE_DEPRECATE = f'{OCH_PREFIX}:RevokeDeprecate'
|
146
|
+
OCH_RENAME_ENTITY = f'{OCH_PREFIX}:RenameEntity'
|
147
|
+
|
148
|
+
|
149
|
+
OCH_ADDED_CLASS = f'{OCH_PREFIX}:addedClass'
|
150
|
+
OCH_DELETED_CLASS = f'{OCH_PREFIX}:removedClass'
|
151
|
+
|
152
|
+
OCH_ADD_SUBCLASS_SOURCE = f'{OCH_PREFIX}:sourceAddSubClass'
|
153
|
+
OCH_ADD_SUBCLASS_TARGET = f'{OCH_PREFIX}:targetAddSubClass'
|
154
|
+
|
155
|
+
OCH_REMOVE_SUBCLASS_SOURCE = f'{OCH_PREFIX}:sourceRemoveSubClass'
|
156
|
+
OCH_REMOVE_SUBCLASS_TARGET = f'{OCH_PREFIX}:targetRemoveSubClass'
|
157
|
+
|
158
|
+
OCH_ADD_EQUIVALENT_CLASS_SOURCE = f'{OCH_PREFIX}:sourceAddEquivalentClass'
|
159
|
+
OCH_ADD_EQUIVALENT_CLASS_TARGET = f'{OCH_PREFIX}:targetAddEquivalentClass'
|
160
|
+
|
161
|
+
OCH_REMOVE_EQUIVALENT_CLASS_SOURCE = f'{OCH_PREFIX}:sourceRemoveEquivalentClass'
|
162
|
+
OCH_REMOVE_EQUIVALENT_CLASS_TARGET = f'{OCH_PREFIX}:targetRemoveEquivalentClass'
|
163
|
+
|
164
|
+
OCH_ADD_DISJOINT_CLASS_SOURCE = f'{OCH_PREFIX}:sourceAddDisjointClass'
|
165
|
+
OCH_ADD_DISJOINT_CLASS_TARGET = f'{OCH_PREFIX}:targetAddDisjointClass'
|
166
|
+
|
167
|
+
OCH_REMOVE_DISJOINT_CLASS_SOURCE = f'{OCH_PREFIX}:sourceRemoveDisjointClass'
|
168
|
+
OCH_REMOVE_DISJOINT_CLASS_TARGET = f'{OCH_PREFIX}:targetRemoveDisjointClass'
|
169
|
+
|
170
|
+
OCH_ADDED_OBJECT_PROPERTY = f'{OCH_PREFIX}:addedObjectProperty'
|
171
|
+
|
172
|
+
OCH_ADDED_DATA_PROPERTY = f'{OCH_PREFIX}:addedDataProperty'
|
173
|
+
|
174
|
+
OCH_REMOVED_DATA_PROPERTY = f'{OCH_PREFIX}:removedDataProperty'
|
175
|
+
|
176
|
+
OCH_REMOVED_OBJECT_PROPERTY = f'{OCH_PREFIX}:removedObjectProperty'
|
177
|
+
|
178
|
+
OCH_ADDED_DOMAIN = f'{OCH_PREFIX}:addedDomain'
|
179
|
+
OCH_REMOVED_DOMAIN = f'{OCH_PREFIX}:removedDomain'
|
180
|
+
OCH_ADDED_OBJECT_RANGE= f'{OCH_PREFIX}:addedObjectRange'
|
181
|
+
OCH_REMOVED_OBJECT_RANGE= f'{OCH_PREFIX}:removedObjectRange'
|
182
|
+
OCH_ADDED_DATA_RANGE= f'{OCH_PREFIX}:addedDataRange'
|
183
|
+
OCH_REMOVED_DATA_RANGE= f'{OCH_PREFIX}:removedDataRange'
|
184
|
+
OCH_ADDED_DOMAIN_TO_PROPERTY = f'{OCH_PREFIX}:addedDomainToProperty'
|
185
|
+
OCH_REMOVED_DOMAIN_TO_PROPERTY = f'{OCH_PREFIX}:removedDomainFromProperty'
|
186
|
+
OCH_ADDED_RANGE_TO_PROPERTY = f'{OCH_PREFIX}:addedRangeToProperty'
|
187
|
+
OCH_REMOVED_RANGE_TO_PROPERTY = f'{OCH_PREFIX}:removedRangeFromProperty'
|
188
|
+
OCH_DEPRECATED_ENTITY = f'{OCH_PREFIX}:deprecatedEntity'
|
189
|
+
OCH_UNDEPRECATED_ELEMENT= f'{OCH_PREFIX}:undeprecatedElement'
|
190
|
+
OCH_OLD_NAME = f'{OCH_PREFIX}:outdatedEntityName'
|
191
|
+
OCH_NEW_NAME = f'{OCH_PREFIX}:renamedEntityName'
|
192
|
+
OCH_ADD_EQUIVALENT_CLASS = f'{OCH_PREFIX}:AddEquivalentClass'
|
193
|
+
OCH_REMOVE_EQUIVALENT_CLASS = f'{OCH_PREFIX}:RemoveEquivalentClass'
|
194
|
+
OCH_ADD_DISJOINT_CLASS = f'{OCH_PREFIX}:AddDisjointClass'
|
195
|
+
OCH_REMOVE_DISJOINT_CLASS = f'{OCH_PREFIX}:RemoveDisjointClass'
|
196
|
+
|
197
|
+
OCH_ADD_CHARACTERISTIC = f'{OCH_PREFIX}:AddCharacteristic'
|
198
|
+
OCH_REMOVE_CHARACTERISTIC = f'{OCH_PREFIX}:RemoveCharacteristic'
|
199
|
+
OCH_ADDED_CHARACTERISTIC = f'{OCH_PREFIX}:addedCharacteristic'
|
200
|
+
OCH_REMOVED_CHARACTERISTIC = f'{OCH_PREFIX}:removedCharacteristic'
|
201
|
+
OCH_ADDED_CHARACTERISTIC_TO_PROPERTY = f'{OCH_PREFIX}:addedCharacteristicToProperty'
|
202
|
+
OCH_REMOVED_CHARACTERISTIC_FROM_PROPERTY = f'{OCH_PREFIX}:removedCharacteristicFromProperty'
|
203
|
+
|
204
|
+
OCH_ADD_INVERSE_PROPERTY = f'{OCH_PREFIX}:AddInverseProperty'
|
205
|
+
OCH_REMOVE_INVERSE_PROPERTY = f'{OCH_PREFIX}:RemoveInverseProperty'
|
206
|
+
OCH_ADD_INVERSE_PROPERTY_SOURCE = f'{OCH_PREFIX}:sourceAddInverseProperty'
|
207
|
+
OCH_ADD_INVERSE_PROPERTY_TARGET = f'{OCH_PREFIX}:targetAddInverseProperty'
|
208
|
+
OCH_REMOVE_INVERSE_PROPERTY_SOURCE = f'{OCH_PREFIX}:sourceRemoveInverseProperty'
|
209
|
+
OCH_REMOVE_INVERSE_PROPERTY_TARGET = f'{OCH_PREFIX}:targetRemoveInverseProperty'
|
210
|
+
|
211
|
+
OCH_ADD_DISJOINT_PROPERTY = f'{OCH_PREFIX}:AddDisjointProperty'
|
212
|
+
OCH_REMOVE_DISJOINT_PROPERTY = f'{OCH_PREFIX}:RemoveDisjointProperty'
|
213
|
+
OCH_ADD_DISJOINT_PROPERTY_SOURCE = f'{OCH_PREFIX}:sourceAddDisjointProperty'
|
214
|
+
OCH_ADD_DISJOINT_PROPERTY_TARGET = f'{OCH_PREFIX}:targetAddDisjointProperty'
|
215
|
+
OCH_REMOVE_DISJOINT_PROPERTY_SOURCE = f'{OCH_PREFIX}:sourceRemoveDisjointProperty'
|
216
|
+
OCH_REMOVE_DISJOINT_PROPERTY_TARGET = f'{OCH_PREFIX}:targetRemoveDisjointProperty'
|
217
|
+
|
218
|
+
OCH_ADD_SUBPROPERTY = f'{OCH_PREFIX}:AddSubProperty'
|
219
|
+
OCH_REMOVE_SUBPROPERTY = f'{OCH_PREFIX}:RemoveSubProperty'
|
220
|
+
OCH_ADD_SUBPROPERTY_SOURCE = f'{OCH_PREFIX}:sourceAddSubProperty'
|
221
|
+
OCH_ADD_SUBPROPERTY_TARGET = f'{OCH_PREFIX}:targetAddSubProperty'
|
222
|
+
OCH_REMOVE_SUBPROPERTY_SOURCE = f'{OCH_PREFIX}:sourceRemoveSubProperty'
|
223
|
+
OCH_REMOVE_SUBPROPERTY_TARGET = f'{OCH_PREFIX}:targetRemoveSubProperty'
|
224
|
+
|
225
|
+
##############################################################################
|
226
|
+
############################# RDFS&OWL CONSTANTS ###########################
|
227
|
+
##############################################################################
|
228
|
+
OWL_PREFIX = 'owl'
|
229
|
+
OWL_URI = 'http://www.w3.org/2002/07/owl#'
|
230
|
+
OWL_CLASS = '{OWL_PREFIX}:Class'
|
231
|
+
OWL_CLASS_URI = 'http://www.w3.org/2002/07/owl#Class'
|
232
|
+
OWL_DATA_PROPERTY = f'{OWL_PREFIX}:DatatypeProperty'
|
233
|
+
OWL_DATA_PROPERTY_URI = 'http://www.w3.org/2002/07/owl#DatatypeProperty'
|
234
|
+
OWL_OBJECT_PROPERTY = f'{OWL_PREFIX}:ObjectProperty'
|
235
|
+
OWL_OBJECT_PROPERTY_URI = 'http://www.w3.org/2002/07/owl#ObjectProperty'
|
236
|
+
OWL_FUNCTIONAL_PROPERTY_URI = f'{OWL_URI}FunctionalProperty'
|
237
|
+
OWL_SYMMETRIC_PROPERTY = f'{OWL_PREFIX}:SymmetricProperty'
|
238
|
+
OWL_SYMMETRIC_PROPERTY_URI = f'{OWL_URI}SymmetricProperty'
|
239
|
+
OWL_ASYMMETRIC_PROPERTY = f'{OWL_PREFIX}:AsymmetricProperty'
|
240
|
+
OWL_ASYMMETRIC_PROPERTY_URI = f'{OWL_URI}AsymmetricProperty'
|
241
|
+
OWL_REFLEXIVE_PROPERTY = f'{OWL_PREFIX}:ReflexiveProperty'
|
242
|
+
OWL_REFLEXIVE_PROPERTY_URI = f'{OWL_URI}ReflexiveProperty'
|
243
|
+
OWL_IRREFLEXIVE_PROPERTY = f'{OWL_PREFIX}:IrreflexiveProperty'
|
244
|
+
OWL_IRREFLEXIVE_PROPERTY_URI = f'{OWL_URI}IrreflexiveProperty'
|
245
|
+
OWL_INVERSE_FUNCTIONAL_PROPERTY = f'{OWL_PREFIX}:InverseFunctionalProperty'
|
246
|
+
OWL_INVERSE_FUNCTIONAL_PROPERTY_URI = f'{OWL_URI}InverseFunctionalProperty'
|
247
|
+
OWL_TRANSITIVE_PROPERTY = f'{OWL_PREFIX}:TransitiveProperty'
|
248
|
+
OWL_TRANSITIVE_PROPERTY_URI = f'{OWL_URI}TransitiveProperty'
|
249
|
+
|
250
|
+
OCH_ADD_EQUIVALENT_PROPERTY = f'{OCH_PREFIX}:AddEquivalentProperty'
|
251
|
+
OCH_REMOVE_EQUIVALENT_PROPERTY = f'{OCH_PREFIX}:RemoveEquivalentProperty'
|
252
|
+
OCH_ADD_EQUIVALENT_PROPERTY_SOURCE = f'{OCH_PREFIX}:sourceAddEquivalentProperty'
|
253
|
+
OCH_ADD_EQUIVALENT_PROPERTY_TARGET = f'{OCH_PREFIX}:targetAddEquivalentProperty'
|
254
|
+
OCH_REMOVE_EQUIVALENT_PROPERTY_SOURCE = f'{OCH_PREFIX}:sourceRemoveEquivalentProperty'
|
255
|
+
OCH_REMOVE_EQUIVALENT_PROPERTY_TARGET = f'{OCH_PREFIX}:targetRemoveEquivalentProperty'
|
256
|
+
|
257
|
+
RDFS_DOMAIN = 'rdfs:domain'
|
258
|
+
RDFS_RANGE = 'rdfs:range'
|
259
|
+
RDFS_SUBCLASS = 'rdfs:subClassOf'
|
260
|
+
PROV_PREFIX = 'prov'
|
261
|
+
PROV_URI = 'http://www.w3.org/ns/prov#'
|
262
|
+
PROV_WAS_DERIVED_FROM = f'{PROV_PREFIX}:wasDerivedFrom'
|
263
|
+
|
264
|
+
logger = logging.getLogger(__name__)
|
265
|
+
coloredlogs.install(level='DEBUG', fmt='%(asctime)s,%(msecs)03d | %(levelname)s: %(message)s')
|