private void addEntailedKBSuccessors(OWLObjectSomeValuesFrom some) {
    TRACKER.start(StaticValues.TIME_KB_SUCCESSORS, BlockOutputMode.COMPLETE, true);
    // add all role-successors entailed by the TBox
    addEntailedTBoxSuccessors(some, m_normalize); // for KB mode only normalize TBox contained roles

    DomainNode<?> toNode = getDomainElement(some.getFiller());

    OWLClass someClass = m_ontologyOperator.getFlatteningTransformer().getIntermediary(some);

    long start = System.currentTimeMillis();
    //		StatStore.getInstance().enterValue("instance accessing", 1.0);
    NodeSet<OWLNamedIndividual> instances =
        m_ontologyOperator.getReasoner().getInstances(someClass, false);
    sum += System.currentTimeMillis() - start;
    //		NodeSet<OWLNamedIndividual> instances =
    // m_ontologyOperator.getReasoner().getInstances(getClassRepresentation(some), false);
    //		LOG.fine(" creating successors to " + some + " from instances: " + instances.toString());
    Iterator<Node<OWLNamedIndividual>> it1 = instances.iterator();
    while (it1.hasNext()) {
      Iterator<OWLNamedIndividual> it2 = it1.next().iterator();
      while (it2.hasNext()) {
        DomainNode<?> from = m_domain.getDomainNode(it2.next());
        if (from != null) {
          //					if(!isSuccessorRepresented(from, getDomainElement(some.getFiller()),
          // (OWLObjectProperty)some.getProperty())){
          from.addSuccessor((OWLObjectProperty) some.getProperty(), toNode);
          //					}
        }
      }
    }
    TRACKER.stop(StaticValues.TIME_KB_SUCCESSORS);
  }
 @Override
 public void visit(OWLObjectSomeValuesFrom desc) {
   desc.getProperty().accept(this);
   OWLObjectPropertyExpression prop = (OWLObjectPropertyExpression) obj;
   desc.getFiller().accept(this);
   OWLClassExpression filler = (OWLClassExpression) obj;
   obj = dataFactory.getOWLObjectSomeValuesFrom(prop, filler);
 }
Esempio n. 3
0
 @Override
 public void visit(OWLObjectSomeValuesFrom node) {
   write(SOME);
   writeSpace();
   node.getProperty().accept(this);
   writeSpace();
   writeNested(node.getFiller());
 }
Esempio n. 4
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb
  * .owlapi.model.OWLObjectSomeValuesFrom)
  */
 @Override
 public void visit(OWLObjectSomeValuesFrom axiom) {
   sb.append(" ");
   sb.append(RestrictionConcept.Restriction.VALUE_RESTRICTION.getId());
   sb.append(" ");
   axiom.getProperty().accept(this);
   sb.append(". (");
   axiom.getFiller().accept(this);
   sb.append(")");
 }
 @Override
 public void visit(OWLObjectSomeValuesFrom ce) {
   if (isTop(ce.getFiller())) {
     constructs.add(AL);
   } else {
     constructs.add(E);
   }
   ce.getProperty().accept(this);
   ce.getFiller().accept(this);
 }
  public static void main(String[] args) throws Exception {
    String catalog = args[0];
    String file = args[1];
    final ParserWrapper pw = new ParserWrapper();
    pw.addIRIMapper(new CatalogXmlIRIMapper(catalog));
    final OWLOntology ontology = pw.parse(file);
    final OWLGraphWrapper g = new OWLGraphWrapper(ontology);
    OWLObjectProperty part_of = g.getOWLObjectPropertyByIdentifier("part_of");
    OWLObjectProperty has_part = g.getOWLObjectPropertyByIdentifier("has_part");
    OWLObjectProperty regulates = g.getOWLObjectPropertyByIdentifier("regulates");
    OWLObjectProperty negatively_regulates =
        g.getOWLObjectPropertyByIdentifier("negatively_regulates");
    OWLObjectProperty positively_regulates =
        g.getOWLObjectPropertyByIdentifier("positively_regulates");
    final OWLClassFilter filter =
        new OWLClassFilter() {

          @Override
          public boolean use(OWLClass cls) {
            String id = g.getIdentifier(cls.getIRI());
            return id.startsWith("GO:");
          }
        };
    Set<OWLObjectProperty> props = Sets.newHashSet(part_of);
    Map<OWLClass, Set<OWLObjectSomeValuesFrom>> expressions =
        getExpressions(ontology, props, filter);
    List<OWLClass> classes = new ArrayList<OWLClass>(expressions.keySet());
    Collections.sort(classes);
    OWLPrettyPrinter pp = new OWLPrettyPrinter(g);
    int count = 0;
    for (OWLClass cls : classes) {
      Set<OWLObjectSomeValuesFrom> svfs = expressions.get(cls);
      for (OWLObjectSomeValuesFrom svf : svfs) {
        StringBuilder sb = new StringBuilder();
        sb.append(pp.render(cls)).append("\t");
        sb.append(pp.render(svf.getProperty())).append("\t");
        sb.append(pp.render(svf.getFiller()));
        System.out.println(sb);
        count += 1;
      }
    }
    System.out.println("Count: " + count);
  }
 @Override
 public void visit(OWLObjectSomeValuesFrom desc) {
   handleObject(desc);
   desc.getProperty().accept(this);
   desc.getFiller().accept(this);
 }
  private void addEntailedTBoxSuccessors(OWLObjectSomeValuesFrom some, boolean doNormalizing) {
    //		StatStore.getInstance().enterValue("lookup " + some.getFiller(), 1.0);
    //		StatStore.getInstance().enterValue("restrictions handled", 1.0);
    TRACKER.start(StaticValues.TIME_TBOX_SUCCESSORS, BlockOutputMode.COMPLETE, true);
    //		TRACKER.start("fetch domain element and intermediary", BlockOutputMode.COMPLETE, true);
    DomainNode<?> toNode = getDomainElement(some.getFiller());
    // the super class, intermediary stands for (some r B)
    OWLClass superClass = m_ontologyOperator.getFlatteningTransformer().getIntermediary(some);
    //		TRACKER.stop("fetch domain element and intermediary");
    // add successors from all
    //		TRACKER.start("query elk", BlockOutputMode.COMPLETE, true);
    //		StatStore.getInstance().enterValue("subclass accessing", 1.0);
    NodeSet<OWLClass> classes = m_ontologyOperator.getReasoner().getSubClasses(superClass, false);

    // fill current class relations from Id
    //		StatStore.getInstance().enterValue("subclass accessing", 1.0);
    currentIdSubClasses = m_ontologyOperator.getReasoner().getSubClasses(some.getFiller(), false);
    //		StatStore.getInstance().enterValue("superclass accessing", 1.0);
    currentIdSuperClasses =
        m_ontologyOperator.getReasoner().getSuperClasses(some.getFiller(), false);
    //		StatStore.getInstance().enterValue("equivalent classes accessing", 1.0);
    currentIdEqClasses = m_ontologyOperator.getReasoner().getEquivalentClasses(some.getFiller());

    //		TRACKER.stop("query elk");
    //		LOG.fine(" creating successors to " + some + ": " + classes.toString());
    Iterator<Node<OWLClass>> nodeIt = classes.iterator();
    while (nodeIt.hasNext()) {
      Iterator<OWLClass> it = nodeIt.next().iterator();
      while (it.hasNext()) {
        DomainNode<?> node = m_domain.getDomainNode(it.next());
        // if it.next() yields no domain node, there exists an ABox identity for it
        // and this case is covered by addEntailedKBSuccessors
        if (node != null) {
          if (doNormalizing) {
            //						if(!isSuccessorRepresented(node, (OWLObjectProperty)some.getProperty(),
            // some.getFiller())){
            TRACKER.start("normalizing and adding", BlockOutputMode.COMPLETE, true);
            if (!isSuccessorRepresented(node, toNode, (OWLObjectProperty) some.getProperty())) {
              removeIncludedSuccessors(
                  (OWLObjectProperty) some.getProperty(), node, some.getFiller());

              node.addSuccessor((OWLObjectProperty) some.getProperty(), toNode);
            }
            TRACKER.stop("normalizing and adding");
          } else {
            node.addSuccessor((OWLObjectProperty) some.getProperty(), toNode);
          }
        }
      }
    }
    // add all equivalent class successors
    //		TRACKER.start("query elk", BlockOutputMode.COMPLETE, true);
    Iterator<OWLClass> cIt =
        m_ontologyOperator.getReasoner().getEquivalentClasses(superClass).iterator();
    //		TRACKER.stop("query elk");
    while (cIt.hasNext()) {
      DomainNode<?> node = m_domain.getDomainNode(cIt.next());
      if (node != null) {
        if (doNormalizing) {
          //					if(!isSuccessorRepresented(node, (OWLObjectProperty)some.getProperty(),
          // some.getFiller())){
          TRACKER.start("normalizing and adding", BlockOutputMode.COMPLETE, true);
          if (!isSuccessorRepresented(node, toNode, (OWLObjectProperty) some.getProperty())) {
            removeIncludedSuccessors(
                (OWLObjectProperty) some.getProperty(), node, some.getFiller());

            node.addSuccessor((OWLObjectProperty) some.getProperty(), toNode);
          }
          TRACKER.stop("normalizing and adding");
        } else {
          node.addSuccessor((OWLObjectProperty) some.getProperty(), toNode);
        }
      }
    }
    TRACKER.stop(StaticValues.TIME_TBOX_SUCCESSORS);
  }
 public void visit(OWLObjectSomeValuesFrom desc) {
   desc.getProperty().accept(this);
   desc.getFiller().accept(this);
 }
 public void visit(OWLObjectSomeValuesFrom desc) {
   edgeName = desc.getProperty().toString();
 }