Example #1
0
  public void test_exists_simple() {
    Ontology ontology = OntologyFactoryImpl.getInstance().createOntology("");

    Predicate a = predicateFactory.getPredicate("a", 1);
    Predicate c = predicateFactory.getPredicate("c", 1);
    Predicate r = predicateFactory.getPredicate("r", 2);
    OClass ac = descFactory.createClass(a);
    OClass cc = descFactory.createClass(c);
    PropertySomeRestriction er = descFactory.getPropertySomeRestriction(r, false);
    ontology.addConcept(ac.getPredicate());
    ontology.addConcept(cc.getPredicate());
    ontology.addRole(er.getPredicate());

    ontology.addAssertion(OntologyFactoryImpl.getInstance().createSubClassAxiom(er, ac));
    ontology.addAssertion(OntologyFactoryImpl.getInstance().createSubClassAxiom(cc, er));

    DAG res = DAGConstructor.getSigma(ontology);
    res.clean();

    assertTrue(res.getClassNode(ac).getDescendants().contains(res.getClassNode(er)));

    assertEquals(1, res.getClassNode(ac).getDescendants().size());

    assertEquals(0, res.getClassNode(er).getDescendants().size());

    assertEquals(0, res.getClassNode(cc).getDescendants().size());
  }
  @Override
  public void merge(ImmutableOntologyVocabulary v) {
    if (v instanceof OntologyVocabularyImpl) {
      OntologyVocabularyImpl vi = (OntologyVocabularyImpl) v;

      concepts.putAll(vi.concepts);
      objectProperties.putAll(vi.objectProperties);
      dataProperties.putAll(vi.dataProperties);
      annotationProperties.putAll(vi.annotationProperties);
    } else {
      for (OClass oc : v.getClasses())
        if (!oc.isTop() && !oc.isBottom()) concepts.put(oc.getName(), oc);
      for (ObjectPropertyExpression ope : v.getObjectProperties())
        if (!ope.isTop() && !ope.isBottom()) objectProperties.put(ope.getName(), ope);
      for (DataPropertyExpression dpe : v.getDataProperties())
        if (!dpe.isTop() && !dpe.isBottom()) dataProperties.put(dpe.getName(), dpe);
      for (AnnotationProperty ap : v.getAnnotationProperties())
        annotationProperties.put(ap.getName(), ap);
    }
  }
 @Override
 public OClass createClass(String uri) {
   OClass cd = new ClassImpl(uri);
   if (!cd.isBottom() && !cd.isTop()) concepts.put(uri, cd);
   return cd;
 }