Welcome to the Tiny-ME C documentation!¶
Tiny-ME - The Tiny Matchmaking Engine is a multiplatform, lightweight OWL reasoner and matchmaker for the Semantic Web of Everything, developed by SisInf Lab at the Polytechnic University of Bari.
These docs refer to the C interface of the system, which uses Cowl as the axiom provider for the Core component. Both Cowl and the Core are part of the public interface of the C API, so you might want to check their docs as well.
For further information and downloads, please refer to the Tiny-ME homepage.
Usage example¶
Here is a simple example to get you started. To learn more, please refer to the API docs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /*
* This introductory example shows how to perform basic reasoning.
* Error handling is omitted for the sake of simplicity.
*
* @author Ivano Bilenchi
*/
#include "tme_cowl_api.h"
#define ONTO_PATH "test_ontology.owl"
#define CLASS_A "http://onto.owl#A"
#define CLASS_B "http://onto.owl#B"
#define RES "http://onto.owl#res"
#define REQ "http://onto.owl#req"
int main(void) {
// Instantiate a parser and deserialize an ontology.
cowl_api_init();
CowlParser *parser = cowl_parser_get();
CowlOntology *ontology = cowl_parser_parse_ontology(parser, ONTO_PATH, NULL);
cowl_parser_release(parser);
// Instantiate a new reasoner instance.
TmeReasoner *reasoner = tme_reasoner_alloc_ontology(ontology);
// The API comes with a built-in logger.
TmeStringProvider *provider = tme_cowl_string_provider_alloc(ontology);
TmeLogger *logger = tme_logger_alloc_console(provider);
// Perform reasoning tasks, e.g.:
// - Classification
tme_reasoner_classify(reasoner);
tme_logger_log_taxonomy(logger, reasoner);
// - Coherence
bool coherent = tme_reasoner_is_coherent(reasoner);
tme_logger_logf(logger, "The ontology is %scoherent.\n", coherent ? "" : "in");
// - Subsumption
CowlClass *class_a = cowl_class_from_static(CLASS_A);
CowlClass *class_b = cowl_class_from_static(CLASS_B);
bool subsumed = tme_reasoner_concept_subsumes(reasoner,
tme_cowl_class_to_atomic(class_a),
tme_cowl_class_to_atomic(class_b));
char const *fmt = CLASS_B " is %ssubsumed by " CLASS_A "\n";
tme_logger_logf(logger, fmt, subsumed ? "" : "not ");
cowl_class_release(class_a);
cowl_class_release(class_b);
// - Matchmaking
CowlNamedInd *res_ind = cowl_named_ind_from_static(RES);
CowlNamedInd *req_ind = cowl_named_ind_from_static(REQ);
TmeAtomicIndividual res = tme_cowl_named_ind_to_atomic(res_ind);
TmeAtomicIndividual req = tme_cowl_named_ind_to_atomic(req_ind);
if (tme_reasoner_individual_is_compatible(reasoner, res, req)) {
TmeAbduction abd = tme_reasoner_individual_abduce(reasoner, res, req);
tme_logger_log_abduction(logger, abd);
tme_abduction_deinit(abd);
} else {
TmeContraction con = tme_reasoner_individual_contract(reasoner, res, req);
tme_logger_log_contraction(logger, con);
tme_contraction_deinit(con);
}
cowl_named_ind_release(res_ind);
cowl_named_ind_release(req_ind);
// Clean up.
tme_logger_free(logger);
tme_cowl_string_provider_free(provider);
tme_reasoner_free(reasoner);
cowl_ontology_release(ontology);
return EXIT_SUCCESS;
}
|