Skip to content

Commit b919377

Browse files
authored
Merge pull request #204 from dice-group/converter-fix
Converter fix
2 parents 28e23c3 + fbfd345 commit b919377

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

owlapy/converter.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def convert(self, root_variable: str,
132132
self.for_all_de_morgan = for_all_de_morgan
133133
self.named_individuals = named_individuals
134134
# # if named_individuals is True, we return only entities that are instances of owl:NamedIndividual
135-
# if named_individuals:
136-
# self.append_triple(root_variable, 'a', f"<{OWLRDFVocabulary.OWL_NAMED_INDIVIDUAL.as_str()}>")
135+
if named_individuals:
136+
self.append_triple(root_variable, 'a', f"<{OWLRDFVocabulary.OWL_NAMED_INDIVIDUAL.as_str()}>")
137137
with self.stack_variable(root_variable):
138138
with self.stack_parent(ce):
139139
self.process(ce)
@@ -270,11 +270,7 @@ def _(self, ce: OWLObjectComplementOf):
270270
# the exclusion of "?x ?p ?o" results in the group graph pattern to just return true or false (not bindings)
271271
# as a result, we need to comment out the if-clause of the following line
272272
# if not self.in_intersection and self.modal_depth == 1:
273-
# if namedIndividual is set to True, do not use variables --> restrict the subject to instances of NamedIndividual
274-
if self.named_individuals:
275-
self.append_triple(subject, "a", f"<{OWLRDFVocabulary.OWL_NAMED_INDIVIDUAL.as_str()}>")
276-
else:
277-
self.append_triple(subject, self.mapping.new_individual_variable(), self.mapping.new_individual_variable())
273+
self.append_triple(subject, self.mapping.new_individual_variable(), self.mapping.new_individual_variable())
278274

279275
self.append("FILTER NOT EXISTS { ")
280276
# process the concept after the ¬
@@ -627,6 +623,8 @@ def as_query(self,
627623
q.append(f"<{x.to_string_id()}>")
628624
q.append("} . ")
629625
qs.extend(q)
626+
if named_individuals:
627+
qs.append(f"{root_variable} a <{OWLRDFVocabulary.OWL_NAMED_INDIVIDUAL.as_str()}> . ")
630628
qs.extend(tp)
631629
qs.append(" }")
632630

@@ -643,10 +641,12 @@ def as_confusion_matrix_query(self,
643641
for_all_de_morgan: bool = True,
644642
named_individuals: bool = False) -> str:
645643
# get the graph pattern corresponding to the provided class expression (ce)
646-
graph_pattern_str = "".join(self.convert(root_variable,
647-
ce,
648-
for_all_de_morgan=for_all_de_morgan,
649-
named_individuals=named_individuals))
644+
tp = self.convert(root_variable, ce, for_all_de_morgan=for_all_de_morgan, named_individuals=named_individuals)
645+
if named_individuals:
646+
named_individual_triple = f"{root_variable} a <{OWLRDFVocabulary.OWL_NAMED_INDIVIDUAL.as_str()}> . "
647+
graph_pattern_str = named_individual_triple + "".join(tp)
648+
else:
649+
graph_pattern_str = "".join(tp)
650650
# preparation for the final query
651651

652652
# required to compute false negatives

0 commit comments

Comments
 (0)