Skip to content

Commit 2d3a65b

Browse files
committed
Feedback from PR
1 parent f6d48e2 commit 2d3a65b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

case_utils/case_validate/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def concept_is_cdo_concept(n_concept: rdflib.URIRef) -> bool:
7777
Determine if a concept is part of the CDO ontology.
7878
7979
:param n_concept: The concept to check.
80-
:return: whether the concept is part of the CDO ontology.
80+
:return: whether the concept is part of the CDO ontologies.
8181
"""
8282
concept_iri = str(n_concept)
8383
return concept_iri.startswith(
@@ -95,12 +95,14 @@ def get_ontology_graph(
9595
:param supplemental_graphs: a list of supplemental graphs to use. If None, no supplemental graphs will be used.
9696
:return: the ontology graph against which to validate the data graph.
9797
"""
98+
if not case_version or case_version == "none":
99+
case_version = CURRENT_CASE_VERSION
100+
98101
ontology_graph = rdflib.Graph()
99-
if case_version and case_version != "none":
100-
ttl_filename = case_version + ".ttl"
101-
_logger.debug("ttl_filename = %r.", ttl_filename)
102-
ttl_data = importlib.resources.read_text(case_utils.ontology, ttl_filename)
103-
ontology_graph.parse(data=ttl_data, format="turtle")
102+
ttl_filename = case_version + ".ttl"
103+
_logger.debug("ttl_filename = %r.", ttl_filename)
104+
ttl_data = importlib.resources.read_text(case_utils.ontology, ttl_filename)
105+
ontology_graph.parse(data=ttl_data, format="turtle")
104106
if supplemental_graphs:
105107
for arg_ontology_graph in supplemental_graphs:
106108
_logger.debug("arg_ontology_graph = %r.", arg_ontology_graph)
@@ -112,11 +114,11 @@ def get_invalid_cdo_concepts(
112114
data_graph: Graph, ontology_graph: Graph
113115
) -> Set[rdflib.URIRef]:
114116
"""
115-
Get the set of concepts in the data graph that are not part of the CDO ontology.
117+
Get the set of concepts in the data graph that are not part of the CDO ontologies.
116118
117119
:param data_graph: The data graph to validate.
118120
:param ontology_graph: The ontology graph to use for validation.
119-
:return: The list of concepts in the data graph that are not part of the CDO ontology.
121+
:return: The set of concepts in the data graph that are not part of the CDO ontologies.
120122
"""
121123
# Construct set of CDO concepts for data graph concept-existence review.
122124
cdo_concepts: Set[rdflib.URIRef] = set()
@@ -186,6 +188,7 @@ def validate(
186188
case_version: Optional[str] = None,
187189
supplemental_graphs: Optional[List[str]] = None,
188190
abort_on_first: bool = False,
191+
inference: Optional[str] = "none",
189192
) -> ValidationResult:
190193
"""
191194
Validate the given data graph against the given CASE ontology version and supplemental graphs.
@@ -194,6 +197,7 @@ def validate(
194197
:param case_version: The version of the CASE ontology to use. If None, the most recent version will be used.
195198
:param supplemental_graphs: The supplemental graphs to use. If None, no supplemental graphs will be used.
196199
:param abort_on_first: Whether to abort on the first validation error.
200+
:param inference: The type of inference to use. If "none", no inference will be used.
197201
:return: The validation result object containing the defined properties.
198202
"""
199203
# Convert the data graph string to a rdflib.Graph object.
@@ -213,7 +217,7 @@ def validate(
213217
data_graph,
214218
shacl_graph=ontology_graph,
215219
ont_graph=ontology_graph,
216-
inference="none",
220+
inference=inference,
217221
meta_shacl=False,
218222
abort_on_first=abort_on_first,
219223
allow_infos=False,

0 commit comments

Comments
 (0)