Using Mini-ME Swift

You can try Mini-ME Swift as described in the following examples

Use Mini-ME Swift within iOS/macOS applications

  1. Download the OWL API for iOS framework from its public repository. Follow instructions over there to compile it and add it to the embedded binaries section of your Xcode project.
  2. Download the Mini-ME Swift framework and add it to the embedded binaries section of your Xcode project.
  3. Include both OWLAPI and MiniME in any source file you want to use Mini-ME in.
Ontology Classification - Shows how to classify an ontology

let ontologyUrl = Bundle.main.url(forResource: "ontology", withExtension: "owl")!
let manager = OWLManager.createOWLOntologyManager()

if let ontology = try? manager.loadOntologyFromDocument(at: ontologyUrl) {
	let reasoner = MicroReasoner(ontology: ontology)
	reasoner.kb.classify()
}
							

Ontology Consistency - Shows how to check the coherence of an ontology

let ontologyUrl = Bundle.main.url(forResource: "ontology", withExtension: "owl")!
let manager = OWLManager.createOWLOntologyManager()

if let ontology = try? manager.loadOntologyFromDocument(at: ontologyUrl) {
	let reasoner = MicroReasoner(ontology: ontology)
	let consistent = reasoner.isConsistent()

	print("The ontology is " + (consistent ? "consistent" : "not consistent"))
}
							

Class Satisfiability - Shows how to check the satisfiability of a class

let ontologyUrl = Bundle.main.url(forResource: "ontology", withExtension: "owl")!
let manager = OWLManager.createOWLOntologyManager()

if let ontology = try? manager.loadOntologyFromDocument(at: ontologyUrl) {
	let reasoner = MicroReasoner(ontology: ontology)
	let satisfiable = reasoner.isSatisfiable(classWithIri: OWLIRI(string: "http://a.com/onto.owl#class"))

	print("The class is " + (satisfiable ? "satisfiable" : "not satisfiable"))
}
							

Concept Abduction and Contraction - Shows how to use the Abduction and Contraction non-standard inference services

let resourceOntologyUrl = Bundle.main.url(forResource: "resource", withExtension: "owl")!
let requestOntologyUrl = Bundle.main.url(forResource: "request", withExtension: "owl")!
let manager = OWLManager.createOWLOntologyManager()

guard let resourceOntology = try? manager.loadOntologyFromDocument(at: resourceOntologyUrl),
	let requestOntology = try? manager.loadOntologyFromDocument(at: requestOntologyUrl) else {
	return
}

let reasoner = MicroReasoner(ontology: resourceOntology)
reasoner.loadRequest(from: requestOntology)

for request in reasoner.requestIndividuals.keys {
	for resource in reasoner.resourceIndividuals.keys {
		let compatible = reasoner.compatibility(betweenResource: resource, andRequest: request)!

		if compatible {
			let abduction = reasoner.abduction(withResource: resource, forRequest: request)!
			print("Abduction between resource \"\(resource)\" and request \"\(request)\":")
			print("Hypotesis: \(abduction.hypotesis)")
			print("Penalty: \(abduction.penalty)\n")
		} else {
			let contraction = reasoner.contraction(withResource: resource, forRequest: request)!
			print("Contraction between resource \"\(resource)\" and request \"\(request)\":")
			print("Keep: \(contraction.keep)")
			print("Give up: \(contraction.giveUp)")
			print("Penalty: \(contraction.penalty)\n")
		}
	}
}
							

Concept Covering - Shows how to use the Concept Covering non-standard inference service

let resourceOntologyUrl = Bundle.main.url(forResource: "resource", withExtension: "owl")!
let requestOntologyUrl = Bundle.main.url(forResource: "request", withExtension: "owl")!
let manager = OWLManager.createOWLOntologyManager()

guard let resourceOntology = try? manager.loadOntologyFromDocument(at: resourceOntologyUrl),
	let requestOntology = try? manager.loadOntologyFromDocument(at: requestOntologyUrl) else {
	return
}

let reasoner = MicroReasoner(ontology: resourceOntology)
reasoner.loadRequest(from: requestOntology)

for request in reasoner.requestIndividuals.keys {
	if let composition = reasoner.composition(forRequest: request) {
		print("Composition for request: \"\(request)\"")
		print("Cover resources: \(composition.coverResources.map({ $0.iri.string }).joined(separator: ", "))")
		print("Uncovered part: \(composition.uncoveredRequest)\n")
	}
}
							

Evaluate Mini-ME Swift

Correctness of the returned results and performance (in terms of turnaround time and peak memory) can be evaluated by launching Mini-ME Swift from the command line, via either a test framework or by directly invoking a command line wrapper, as explained in the upcoming sections.

Test framework

Instructions on how to install, configure and use the test framework are available on its public repository. Datasets and reasoners used for performance evaluation should be unpacked in the root directory of the test framework.

Command line wrapper

The MiniME-cli tool, available in the reasoners archive, is internally used by the test framework in order to accurately compute turnaround times for some of the supported reasoning tasks. For standard tasks, it also provides the output of the inference service. It can be run manually as follows:

  • ./MiniME-cli classification -i <input ontology> [-o <output file>]: classifies the specified OWL ontology, printing the inferred taxonomy in the output file.
  • ./MiniME-cli consistency -i <input ontology>: checks the consistency of the specified OWL ontology.
  • ./MiniME-cli abduction-contraction -i <resource OWL file> -r <request OWL file>: evaluates non-standard inference services on the specified resource OWL file (containing ontology and a set of resource individuals) and request OWL file (containing the request individual expressed with respect to the same ontology).