Skip to content

Commit

Permalink
Account for owl:Thing and rdfs:Literal when iterating over quantifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed Aug 30, 2024
1 parent abe0fea commit 3d7cd85
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/cowl_data_quant.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
* @file
*/

#include "cowl_data_quant.h"
#include "cowl_any.h"
#include "cowl_data_quant_private.h"
#include "cowl_impl.h"
#include "cowl_iterator.h"
#include "cowl_macros.h"
#include "cowl_object.h"
#include "cowl_object_type.h"
#include "cowl_primitive_flags.h"
#include "cowl_quant_type.h"
#include "cowl_rdfs_vocab.h"
#include <stddef.h>
Expand All @@ -28,3 +31,9 @@ CowlDataRange *cowl_data_quant_get_range(CowlDataQuant *restr) {
CowlDataRange *range = cowl_get_opt_field(restr);
return range ? range : (CowlDataRange *)cowl_rdfs_vocab()->dt.literal;
}

bool cowl_data_quant_iterate_primitives(CowlDataQuant *restr, CowlPrimitiveFlags flags,
CowlIterator *iter) {
return (cowl_iterate_primitives(cowl_data_quant_get_prop(restr), flags, iter) &&
cowl_iterate_primitives(cowl_data_quant_get_range(restr), flags, iter));
}
21 changes: 21 additions & 0 deletions src/cowl_data_quant_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @author Ivano Bilenchi
*
* @copyright Copyright (c) 2024 SisInf Lab, Polytechnic University of Bari
* @copyright <http://swot.sisinflab.poliba.it>
* @copyright SPDX-License-Identifier: EPL-2.0
*
* @file
*/

#ifndef COWL_DATA_QUANT_PRIVATE_H
#define COWL_DATA_QUANT_PRIVATE_H

#include "cowl_data_quant.h" // IWYU pragma: export
#include "cowl_iterator.h"
#include "cowl_primitive_flags.h"

bool cowl_data_quant_iterate_primitives(CowlDataQuant *restr, CowlPrimitiveFlags flags,
CowlIterator *iter);

#endif // COWL_DATA_QUANT_PRIVATE_H
11 changes: 10 additions & 1 deletion src/cowl_obj_quant.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
* @file
*/

#include "cowl_obj_quant.h"
#include "cowl_any.h"
#include "cowl_impl.h"
#include "cowl_iterator.h"
#include "cowl_macros.h"
#include "cowl_obj_quant_private.h"
#include "cowl_object.h"
#include "cowl_object_type.h"
#include "cowl_owl_vocab.h"
#include "cowl_primitive_flags.h"
#include "cowl_quant_type.h"
#include <stddef.h>

Expand All @@ -27,3 +30,9 @@ CowlClsExp *cowl_obj_quant_get_filler(CowlObjQuant *restr) {
CowlClsExp *filler = cowl_get_opt_field(restr);
return filler ? filler : (CowlClsExp *)cowl_owl_vocab()->cls.thing;
}

bool cowl_obj_quant_iterate_primitives(CowlObjQuant *restr, CowlPrimitiveFlags flags,
CowlIterator *iter) {
return (cowl_iterate_primitives(cowl_obj_quant_get_prop(restr), flags, iter) &&
cowl_iterate_primitives(cowl_obj_quant_get_filler(restr), flags, iter));
}
21 changes: 21 additions & 0 deletions src/cowl_obj_quant_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @author Ivano Bilenchi
*
* @copyright Copyright (c) 2024 SisInf Lab, Polytechnic University of Bari
* @copyright <http://swot.sisinflab.poliba.it>
* @copyright SPDX-License-Identifier: EPL-2.0
*
* @file
*/

#ifndef COWL_OBJ_QUANT_PRIVATE_H
#define COWL_OBJ_QUANT_PRIVATE_H

#include "cowl_iterator.h"
#include "cowl_obj_quant.h" // IWYU pragma: export
#include "cowl_primitive_flags.h"

bool cowl_obj_quant_iterate_primitives(CowlObjQuant *restr, CowlPrimitiveFlags flags,
CowlIterator *iter);

#endif // COWL_OBJ_QUANT_PRIVATE_H
6 changes: 6 additions & 0 deletions src/cowl_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "cowl_anon_ind_private.h"
#include "cowl_any.h"
#include "cowl_axiom.h"
#include "cowl_data_quant_private.h"
#include "cowl_entity.h"
#include "cowl_entity_private.h"
#include "cowl_iri.h"
Expand All @@ -21,6 +22,7 @@
#include "cowl_iterator.h"
#include "cowl_literal_private.h"
#include "cowl_manager_private.h"
#include "cowl_obj_quant_private.h"
#include "cowl_object_flags.h"
#include "cowl_object_private.h"
#include "cowl_object_type.h"
Expand Down Expand Up @@ -426,6 +428,10 @@ bool cowl_iterate_primitives(CowlAny *object, CowlPrimitiveFlags flags, CowlIter
case COWL_OT_I_NAMED: return iterate_pf(COWL_PF_NAMED_IND, object, flags, iter);
case COWL_OT_I_ANONYMOUS: return iterate_pf(COWL_PF_ANON_IND, object, flags, iter);
case COWL_OT_OPE_OBJ_PROP: return iterate_pf(COWL_PF_OBJ_PROP, object, flags, iter);
case COWL_OT_CE_OBJ_SOME:
case COWL_OT_CE_OBJ_ALL: return cowl_obj_quant_iterate_primitives(object, flags, iter);
case COWL_OT_CE_DATA_SOME:
case COWL_OT_CE_DATA_ALL: return cowl_data_quant_iterate_primitives(object, flags, iter);
case COWL_OT_ONTOLOGY: return cowl_ontology_iterate_primitives(object, flags, iter, false);
default: return iterate_impl(type, object, flags, iter);
}
Expand Down
2 changes: 1 addition & 1 deletion test/tests/cowl_ontology_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static CowlOntology *onto = NULL;
static ulib_uint const test_onto_imports_count = 1;
static ulib_uint const test_onto_axiom_count = 571;

static ulib_uint const test_primitives_count[] = { 105, 48, 72, 27, 18, 1, 46, 12 };
static ulib_uint const test_primitives_count[] = { 106, 48, 72, 27, 18, 1, 46, 12 };
static ulib_uint const test_primitive_axiom_count[] = { 16, 4, 4, 2, 2, 1, 2, 8 };

static ulib_uint axiom_counts_by_type[COWL_AT_COUNT] = { 0 };
Expand Down

0 comments on commit 3d7cd85

Please sign in to comment.