@Override
 public void visit(OWLObjectPropertyAssertionAxiom axiom) {
   handleObject(axiom);
   axiom.getSubject().accept(this);
   axiom.getProperty().accept(this);
   axiom.getObject().accept(this);
 }
 @Override
 public void visit(OWLObjectPropertyAssertionAxiom axiom) {
   OWLClassExpression sub = oneOf(axiom.getSubject());
   OWLClassExpression sup = factory.getOWLObjectHasValue(axiom.getProperty(), axiom.getObject());
   OWLSubClassOfAxiom ax = factory.getOWLSubClassOfAxiom(sub, sup);
   ax.accept(this);
 }
Ejemplo n.º 3
0
 @Override
 public void visit(OWLObjectPropertyAssertionAxiom axiom) {
   axiom.getProperty().accept(this);
   write("(");
   axiom.getSubject().accept(this);
   write(", ");
   axiom.getObject().accept(this);
   write(")");
 }
Ejemplo n.º 4
0
 @Override
 public void visit(OWLObjectPropertyAssertionAxiom axiom) {
   axiom.getSubject().accept(this);
   OWLIndividual ind = (OWLIndividual) obj;
   axiom.getProperty().accept(this);
   OWLObjectPropertyExpression prop = (OWLObjectPropertyExpression) obj;
   axiom.getObject().accept(this);
   OWLIndividual ind2 = (OWLIndividual) obj;
   obj =
       dataFactory.getOWLObjectPropertyAssertionAxiom(
           prop, ind, ind2, duplicateAxiomAnnotations(axiom));
 }
Ejemplo n.º 5
0
 public void visit(OWLObjectPropertyAssertionAxiom object) {
   Atom atom =
       getRoleAtom(
           object.getProperty(),
           getIndividual(object.getSubject()),
           getIndividual(object.getObject()));
   Collection<OWLAxiom> originalAxioms = m_positiveFacts_map.get(atom);
   if (originalAxioms == null) {
     originalAxioms = new ArrayList<OWLAxiom>();
     m_positiveFacts_map.put(atom, originalAxioms);
   }
   if (originalAxiom != null) originalAxioms.add(originalAxiom);
 }
  @Override
  public CanonicalInterpretation generate(OWLOntology ontology) {
    CanonicalInterpretation canonInterpretation = new CanonicalInterpretation();
    m_domain = new CanonicalDomain();
    canonInterpretation.initDomain(m_domain);

    m_ontologyOperator = OntologyOperator.getOntologyOperator(ontology);
    IDomainElementGenerator elemGen;
    if (isKBMode()) {
      elemGen = new KBDomainElementGenerator();
    } else {
      elemGen = new TBoxDomainElementGenerator();
    }

    if (!isKBMode()) { // TBox + Query mode
      // define class Q as equivalence to the reference expression (query)
      m_referenceClass = getFreshQueryClass("Q");
      insertQueryAxiom(m_referenceClass);
      ((TBoxDomainElementGenerator) elemGen).registerConcept(m_referenceClass);
    }

    OWLAxiomFlatteningTransformer exRestStore =
        m_ontologyOperator.getFlatteningTransformer(); // flattens here
    m_ontologyOperator.getReasoner(isKBMode()); // precomputes inferences

    // the element generator creates all necessary domain elements and adds their instantiators
    elemGen.generate(this, m_keepSmall);
    LOG.info("a total of " + m_classAssociations.size() + " classes are mapped to individuals");

    TRACKER.start(StaticValues.TIME_DOMAIN_SUCCESSORS);
    if (!isKBMode()) { // TBox + Query mode

      // add all successor relations by iterating all known existential restrictions
      for (OWLObjectSomeValuesFrom some : exRestStore.getRestrictions()) {
        addEntailedTBoxSuccessors(some, m_normalize);
      }
    } else { // KB mode (ABox + TBox)
      // add all ABox property assertion successors
      for (OWLAxiom ax : m_ontologyOperator.getOntology().getABoxAxioms(true)) {
        if (ax instanceof OWLObjectPropertyAssertionAxiom) {
          //					LOG.fine("Adding role assertion successor: " + ax);
          OWLObjectPropertyAssertionAxiom pAx = (OWLObjectPropertyAssertionAxiom) ax;
          getDomainElement(pAx.getSubject())
              .addSuccessor(
                  (OWLObjectProperty) pAx.getProperty(), getDomainElement(pAx.getObject()));
        }
      }

      // add all successor relations by iterating all known existential restrictions
      int exR = 1;
      for (OWLObjectSomeValuesFrom some :
          m_ontologyOperator.getFlatteningTransformer().getRestrictions()) {
        if (exR % 1000 == 0) {
          System.out.println(exR + " restrictions handled");
        }
        addEntailedKBSuccessors(some);
        exR++;
      }

      LOG.info("TOTAL TIME FOR INSTANCE RETRIEVAL: " + sum + " ms");

      // normalize later
      // if(m_normalize){ startSimulationComputation(); }

    }
    TRACKER.stop(StaticValues.TIME_DOMAIN_SUCCESSORS);

    /* ************* TEST SPECIFIC STUFF ************** */
    //		LOG.info("Start checking for useless domain nodes ...");
    //		Map<OWLClassExpression, DomainNode<OWLClassExpression>> conceptDomainNodes =
    // canonInterpretation.getDomain().getConceptElements();
    //		Set<DomainNode<OWLClassExpression>> noPredecessors = new
    // HashSet<DomainNode<OWLClassExpression>>();
    //		noPredecessors.addAll(conceptDomainNodes.values());
    //		for(OWLClassExpression ce : conceptDomainNodes.keySet()){
    //			for(OWLObjectProperty r : conceptDomainNodes.get(ce).getSuccessorRoles()){
    //				noPredecessors.removeAll(conceptDomainNodes.get(ce).getSuccessors(r));
    //			}
    //
    //			NodeSet<OWLClass> subClasses =
    // m_ontologyOperator.getReasoner().getSubClasses(ce.asOWLClass(), false);
    //			Node<OWLClass> eqClasses =
    // m_ontologyOperator.getReasoner().getEquivalentClasses(ce.asOWLClass());
    //			for(OWLClassExpression ce2 : conceptDomainNodes.keySet()){
    //				if(!ce.equals(ce2)){
    //					if(subClasses.containsEntity(ce2.asOWLClass())){
    //						LOG.info("Domain node " + conceptDomainNodes.get(ce2) + " represents something more
    // specific than " + conceptDomainNodes.get(ce));
    //					}else if(eqClasses.contains(ce2.asOWLClass())){
    //						LOG.info("Domain node " + conceptDomainNodes.get(ce2) + " is equivalent to " +
    // conceptDomainNodes.get(ce));
    //					}
    //				}
    //			}
    //		}
    //		for(DomainNode<OWLClassExpression> d : noPredecessors){
    //			LOG.info(d + " does not have any predecessors.");
    //			if(d.getSuccessorObjects().isEmpty())
    //				LOG.info(d + " is not connected to the model at all!");
    //		}
    /* ************ END TEST ***************** */

    return canonInterpretation;
  }
 public void visit(OWLObjectPropertyAssertionAxiom axiom) {
   axiom.getProperty().accept(this);
   axiom.getObject().accept(this);
   processAxiomAnnotations(axiom);
 }
 public void visit(OWLObjectPropertyAssertionAxiom axiom) {
   addChildParent(axiom.getSubject(), axiom.getObject(), axiom);
 }
  public boolean retrieveSolutions(String siteNameHash) {
    // use the siteNameHash to access a certain Site individual in the ontology
    // retrieve each Solution individual of this site and use it to re-initialise the Solutions List
    OwlSolution tempSolution;
    OwlSolvedHouse tempSolvedHouse;
    OwlSolvedRoom tempSolvedRoom;

    // first clear the Solution List contents...
    this.solutionsList.clear();

    OWLIndividual tempSiteIndividual =
        OWLFactory.getOWLNamedIndividual(":" + siteNameHash, topIxPrefixManager);
    OWLClassExpression tempSolutionClassExpression =
        OWLFactory.getOWLClass(":Solution", topIxPrefixManager);
    Set<OWLObjectPropertyAssertionAxiom> tempSitePropertyAxioms =
        topIxOnt.getObjectPropertyAssertionAxioms(tempSiteIndividual);

    Set<OWLIndividual> tempSolutionIndividuals =
        new HashSet<>(); // Solution individuals for this particular site. will be filled below...
    Set<OWLIndividual> tempSolvedHouseIndividuals = new HashSet<>();
    Set<OWLIndividual> tempSolvedRoomIndividuals = new HashSet<>();

    // populate the tempSolutionIndividuals Set<OWLIndividual>
    // with the Solution individuals that are solutions of the current Site
    // this block runs through the set of all the object property axioms
    // that have this site as their subject
    // and filters out the ones that are of type "hasSolution"
    for (OWLObjectPropertyAssertionAxiom tempObjPropAssAx : tempSitePropertyAxioms) {
      OWLObjectProperty tempHasSolutionObjectProperty =
          OWLFactory.getOWLObjectProperty(
              IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasSolution"));
      if (tempObjPropAssAx.getProperty() == tempHasSolutionObjectProperty) {
        tempSolutionIndividuals.add(tempObjPropAssAx.getObject());
      }
    }
    // retrieving the site dimensions for this solution set
    // (the site remains the same throughout the plethos of solutions).
    int tempSiteLength = 0;
    int tempSiteWidth = 0;
    OWLDataProperty siteHasLengthProp = OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager);
    OWLDataProperty siteHasWidthProp = OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager);
    Set<OWLDataPropertyAssertionAxiom> tempSiteDataProperties = new HashSet<>();

    tempSiteDataProperties = topIxOnt.getDataPropertyAssertionAxioms(tempSiteIndividual);

    for (OWLDataPropertyAssertionAxiom tempSiteDataProperty : tempSiteDataProperties) {
      if (tempSiteDataProperty.getProperty() == siteHasLengthProp) {
        tempSiteLength = tempSiteDataProperty.getObject().parseInteger();
      }
      if (tempSiteDataProperty.getProperty() == siteHasWidthProp) {
        tempSiteWidth = tempSiteDataProperty.getObject().parseInteger();
      }
    }

    logger.info(tempSolutionIndividuals.size());

    // running every solution individual for/of that particular site in order
    // to extract the solvedHouse's and the solvedRoom's
    // via the hasSolvedHouse and hasSolvedRoom properties.
    int solutionCounter = 0;
    for (OWLIndividual tempSolutionIndividual : tempSolutionIndividuals) {
      tempSolution = new OwlSolution();
      tempSolution.setSolutionID(new Integer(++solutionCounter));

      tempSolution.setSiteLength(new Integer(tempSiteLength));
      tempSolution.setSiteWidth(new Integer(tempSiteWidth));

      // clearing the contents of these two structuresin order to accommodate the solved entities of
      // the next solution.
      tempSolvedHouseIndividuals.clear();
      tempSolvedRoomIndividuals.clear();

      for (OWLObjectPropertyAssertionAxiom tempObjPropAssAx :
          topIxOnt.getObjectPropertyAssertionAxioms(tempSolutionIndividual)) {
        OWLObjectProperty tempHasSolvedHouseObjectProperty =
            OWLFactory.getOWLObjectProperty(
                IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasSolvedHouse"));
        OWLObjectProperty tempHasSolvedRoomObjectProperty =
            OWLFactory.getOWLObjectProperty(
                IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasSolvedRoom"));
        if (tempObjPropAssAx.getProperty() == tempHasSolvedHouseObjectProperty) {
          tempSolvedHouseIndividuals.add(tempObjPropAssAx.getObject());
        } else if (tempObjPropAssAx.getProperty() == tempHasSolvedRoomObjectProperty) {
          tempSolvedRoomIndividuals.add(tempObjPropAssAx.getObject());
        }
      }

      for (OWLIndividual tempSolvedHouseIndividual : tempSolvedHouseIndividuals) {
        tempSolvedHouse = new OwlSolvedHouse();
        for (OWLDataPropertyAssertionAxiom tempDatPropAssAx :
            topIxOnt.getDataPropertyAssertionAxioms(tempSolvedHouseIndividual)) {
          if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasL", topIxPrefixManager))) {
            // logger.info(tempDatPropAssAx.getObject().parseInteger());
            tempSolvedHouse.setSolvedHouseLength(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasW", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseWidth(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseX(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseY(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasLiteral", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseLiteral(tempDatPropAssAx.getObject().getLiteral());
          }
        }
        // logger.info(tempSolvedHouse.getSolvedHouseX()+" "+tempSolvedHouse.getSolvedHouseY());
        tempSolution.getSolvedHouses().add(tempSolvedHouse);
      }

      for (OWLIndividual tempSolvedRoomIndividual : tempSolvedRoomIndividuals) {
        tempSolvedRoom = new OwlSolvedRoom();
        for (OWLDataPropertyAssertionAxiom tempDatPropAssAx :
            topIxOnt.getDataPropertyAssertionAxioms(tempSolvedRoomIndividual)) {
          if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasL", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomLength(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasW", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomWidth(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasH", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomHeight(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomX(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomY(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasZ", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomZ(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasLiteral", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomLiteral(tempDatPropAssAx.getObject().getLiteral());
          }
        }
        tempSolution.getSolvedRooms().add(tempSolvedRoom);
      }
      this.solutionsList.add(tempSolution);
    }

    return true;
  }