Cannot get instances of a class from kernel
Hi,
I am struggling to get the instances of a given class. Here is a simple example, in C (see attached file):
int main ( void )
{
// create kernel
fact_reasoning_kernel* k = fact_reasoning_kernel_new();
// create class C
fact_concept_expression* c = fact_concept(k,"C");
// create I, an instance of C
fact_individual_expression* i = fact_individual(k,"I");
fact_instance_of ( k, i, c);
fact_actor* actor = fact_concept_actor_new();
fact_get_instances ( k, c, &actor);
print2Darray(fact_get_elements_2d(actor));
fact_actor_free(actor);
// we done so let's free memory
fact_reasoning_kernel_free(k);
return 0;
}
The output is the following (I've enabled verbosity):
#!
FaCT++.Kernel: Reasoner for the SROIQ(D) Description Logic, 64-bit
Copyright (C) Dmitry Tsarkov, 2002-2015. Version 1.6.4 (23 August 2015)
(instance I C)
Preprocessing... done in 0 seconds
Consistency checking... done in 0 seconds
Processing query... done in 0 seconds
[
[C ]
[BOTTOM ]
]
I expect I
to be present, since it is an instance of C
. However I only seem to get classes/concepts back, which is surprising. I am not expecting any ConceptExpr
s, rather only IndividualExpr
s. It looks like the kernel is returning the subconcepts/subclasses rather than the instances. Both functions getSubConcepts
and getInstances
look very similar. I can't figure out where getInstances
effectively differs. However my understanding of Fact++'s internals is non-existent.
The workaround I have found so far is to go through my instances one-by-one and ask isInstance
on it. However I suspect that the kernel can give me the same result somehow. This was tested against latest master.
Comments (2)
-
repo owner -
repo owner - changed status to resolved
Current code contains an example of the fact_get_instances() usage in test.c
- Log in to comment
fact_concept_actor_new() creates an actor that collects concepts. If you want to collect and report individuals, you have to call fact_individual_actor_new() instead.