All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.ac.manchester.cs.owl.explanation.JustificationCache Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.0.1
Show newest version
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);
    }
    
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy