protected void loadOntology() { try { manager = OWLManager.createOWLOntologyManager(); URI physicalURI = URI.create(PREFERENCES.getOntologyURL()); // Now do the loading ontology = manager.loadOntologyFromPhysicalURI(physicalURI); manager.setPhysicalURIForOntology(ontology, physicalURI); } catch (final Exception e) { Runnable runnable = new Runnable() { public void run() { JOptionPane.showMessageDialog( null, "Could not create the ontology. (This probably happened\n" + "because the ontology could not be accessed due to network\n" + "problems.)\n" + "[" + e.getMessage() + "]", "Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } }; SwingUtilities.invokeLater(runnable); } }
private OWLDescription createIncludeCoffeeDescription(Set<OWLClass> includeExtras) { OWLObjectProperty prop = this.getNamedObjectProperty(PREFERENCES.getExtrasPropertyName()); // has_extras Set<OWLDescription> classes = new HashSet<OWLDescription>(); classes.add(getCoffeeClass()); // get OWL class for Coffee for (OWLClass extra : includeExtras) { classes.add(manager.getOWLDataFactory().getOWLObjectSomeRestriction(prop, extra)); } return manager.getOWLDataFactory().getOWLObjectIntersectionOf(classes); }
private OWLDescription createExcludeCoffeeDescription(Set<OWLClass> excludeExtras) { OWLObjectProperty prop = this.getNamedObjectProperty(PREFERENCES.getExtrasPropertyName()); // has_extras Set<OWLDescription> classes = new HashSet<OWLDescription>(); // Everything must be a coffee for (OWLClass extra : excludeExtras) { classes.add(manager.getOWLDataFactory().getOWLObjectSomeRestriction(prop, extra)); } // are looking for. return manager.getOWLDataFactory().getOWLObjectUnionOf(classes); }
/** * Creates OWLDescription (query) by given included extras and excluded extras * * @param includeExtras * @param excludeExtras * @return */ private OWLDescription createCoffeeDescription( Set<OWLClass> includeExtras, Set<OWLClass> excludeExtras) { // Include means existential restrictions // Exclude means negated existential restrictions OWLObjectProperty prop = this.getNamedObjectProperty(PREFERENCES.getExtrasPropertyName()); // has_extras // Create a hash set to store the components (existential restrictions) // of our description Set<OWLDescription> classes = new HashSet<OWLDescription>(); // Everything must be a coffee classes.add(getCoffeeClass()); // get OWL class for Coffee // Create the existential restrictions that represent the extras // that we want to include. for (OWLClass extra : includeExtras) { // e.g. hasExtras some ex_A , hasExtras some ex_B classes.add(manager.getOWLDataFactory().getOWLObjectSomeRestriction(prop, extra)); } // Create the negated existential restrictions of the extras that we // want to exclude for (OWLClass excludeExtra : excludeExtras) { // has_topping some topping_A OWLDescription restriction = manager.getOWLDataFactory().getOWLObjectSomeRestriction(prop, excludeExtra); // not (has_topping some topping_A) OWLObjectComplementOf neg = manager.getOWLDataFactory().getOWLObjectComplementOf(restriction); classes.add(neg); } // Bind the whole thing up in an intersection class // to create a concept description of the coffee we // are looking for. return manager.getOWLDataFactory().getOWLObjectIntersectionOf(classes); }
public OWLObjectProperty getTemperatureProperty() { return getNamedObjectProperty(PREFERENCES.getTemperaturePropertyName()); }
public OWLObjectProperty getExtrasProperty() { return getNamedObjectProperty(PREFERENCES.getExtrasPropertyName()); }
static { PREFERENCES = CoffeePreferences.getInstance(); }
public OWLClass getMochaCoffeeClass() { return this.getNamedClass(PREFERENCES.getMochaCoffeeClassName()); }
public OWLClass getGuaFilterCoffeeClass() { return this.getNamedClass(PREFERENCES.getGuaFilterCoffeeClassName()); }
public OWLClass getEspressoCoffeeClass() { return this.getNamedClass(PREFERENCES.getEspressoCoffeeClassName()); }
/** * Gets the main temperature categories. This actually returns the direct named subclasses of the * Temperature class. * * @return A <code>Collection</code> of <code>OWLNamedClasses</code> */ public Collection getTemperatureCategories() throws OWLReasonerException { OWLClass temperatureCls = this.getNamedClass(PREFERENCES.getTemperatureClassName()); return temperatureCls.getSubClasses(ontology); }
/** * Gets the main base categories. This actually returns the direct named subclasses of the Bases * class. * * @return A <code>Collection</code> of <code>OWLNamedClasses</code> */ public Collection getCoffeeBasesCategories() throws OWLReasonerException { OWLClass basesCls = this.getNamedClass(PREFERENCES.getBaseClassName()); return basesCls.getSubClasses(ontology); }