Example #1
0
  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);
    }
  }
Example #2
0
  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);
  }
Example #3
0
  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);
  }
Example #4
0
  /**
   * 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);
  }
Example #5
0
 public OWLObjectProperty getTemperatureProperty() {
   return getNamedObjectProperty(PREFERENCES.getTemperaturePropertyName());
 }
Example #6
0
 public OWLObjectProperty getExtrasProperty() {
   return getNamedObjectProperty(PREFERENCES.getExtrasPropertyName());
 }
Example #7
0
 static {
   PREFERENCES = CoffeePreferences.getInstance();
 }
Example #8
0
 public OWLClass getMochaCoffeeClass() {
   return this.getNamedClass(PREFERENCES.getMochaCoffeeClassName());
 }
Example #9
0
 public OWLClass getGuaFilterCoffeeClass() {
   return this.getNamedClass(PREFERENCES.getGuaFilterCoffeeClassName());
 }
Example #10
0
 public OWLClass getEspressoCoffeeClass() {
   return this.getNamedClass(PREFERENCES.getEspressoCoffeeClassName());
 }
Example #11
0
  /**
   * 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);
  }
Example #12
0
  /**
   * 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);
  }