uk.ac.manchester.cs.owl.explanation.JustificationCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of explanation-workbench Show documentation
Show all versions of explanation-workbench Show documentation
A plug-in that adds explanation facilities to the Protege Desktop ontology editor.
Written by Matthew Horridge during his PhD at the University of Manchester.
package uk.ac.manchester.cs.owl.explanation;
import org.semanticweb.owl.explanation.api.Explanation;
import org.semanticweb.owlapi.model.OWLAxiom;
import java.util.*;
/**
* Author: Matthew Horridge
* Stanford University
* Bio-Medical Informatics Research Group
* Date: 20/03/2012
*/
public class JustificationCache {
private Map>> cache = new HashMap>>();
public boolean contains(OWLAxiom entailment) {
return cache.containsKey(entailment);
}
public Set> get(OWLAxiom entailment) {
Set> explanations = cache.get(entailment);
if(explanations == null) {
return Collections.emptySet();
}
return new HashSet>(explanations);
}
public void put(Explanation explanation) {
Set> expls = cache.get(explanation.getEntailment());
if(expls == null) {
expls = new HashSet>();
cache.put(explanation.getEntailment(), expls);
}
expls.add(explanation);
}
public void put(Set> explanations) {
for(Explanation expl : explanations) {
put(expl);
}
}
public void clear() {
cache.clear();
}
public void clear(OWLAxiom entailment) {
cache.remove(entailment);
}
}