Package edu.pitt.ontology

Examples of edu.pitt.ontology.ILogicExpression


   * @param dpatterns
   * @return
   */
  public static ILogicExpression getMatchingPatterns(IClass dx, IInstance inst){
    // check for multi-pattern
    ILogicExpression result = new LogicExpression(ILogicExpression.OR);
    ILogicExpression exp = dx.getEquivalentRestrictions();
    if(exp.getExpressionType() == ILogicExpression.OR){
      for(int i=0;i<exp.size();i++){
        if(exp.get(i) instanceof ILogicExpression){
          ILogicExpression e = (ILogicExpression) exp.get(i);
          // if this pattern matches
          if(e.evaluate(inst)){
            result.add(exp.get(i));
          }
        }
      }
    }
View Full Code Here


  /**
   * get direct restrictions associated with a given class
   * @return
   */
  public ILogicExpression getNecessaryRestrictions(){
    ILogicExpression exp = new LogicExpression(ILogicExpression.AND);
    if(cls instanceof OWLNamedClass){
      Collection list = cls.getEquivalentClasses();
      for(Object o: ((OWLNamedClass) cls).getSuperclasses(true)){
        RDFSClass c = (RDFSClass) o;
        if(c.isAnonymous() && !list.contains(c)){
          exp.add(convertParameter(c));
        }
      }
    }
    return exp;
  }
View Full Code Here

  /**
   * get direct restrictions associated with a given class
   * @return
   */
  public ILogicExpression getEquivalentRestrictions(){
    ILogicExpression exp = ontology.createLogicExpression();
    exp.setExpressionType(ILogicExpression.AND);
    if(cls instanceof OWLNamedClass){
      ArrayList<PClass> list = new ArrayList<PClass>();
      // get list of anonymous classes
      for(IClass cls : getEquivalentClasses()){
        if(cls.isAnonymous())
          list.add((PClass)cls);
      }
      // if we have just one anonymous class that is an expression
      // return it, else build our own expression from what we've got
      if(list.size() == 1 && list.get(0).getResource() instanceof OWLLogicalClass){
        return list.get(0).getLogicExpression();
      }else{
        // else we've got several equivalent expressions that should be ANDed
        for(PClass pc : list){
          if(pc.isAnonymous()){
            if(pc.getResource() instanceof OWLRestriction){
              exp.add((pc instanceof IRestriction)?pc:new PRestriction((OWLRestriction)pc.getResource(),getOntology()));
            }else if(pc.getResource() instanceof OWLIntersectionClass){
              exp.addAll(pc.getLogicExpression());
            }else if(pc.getResource() instanceof OWLLogicalClass){
              exp.add(pc.getLogicExpression());
            }
          }
        }
      }
    }
View Full Code Here

  /**
   * get direct restrictions associated with a given class
   * @return
   */
  public ILogicExpression getDirectNecessaryRestrictions(){
    ILogicExpression exp = new LogicExpression(ILogicExpression.AND);
    if(cls instanceof OWLNamedClass){
      Collection list = cls.getEquivalentClasses();
      for(Object o: ((OWLNamedClass) cls).getSuperclasses(false)){
        RDFSClass c = (RDFSClass) o;
        if(c.isAnonymous() && !list.contains(c)){
          exp.add(convertParameter(c));
        }
      }
    }
    return exp;
 
View Full Code Here

   */
  public ILogicExpression getLogicExpression(){
   
    // if we have a union or intersection class
    if(resource instanceof OWLNAryLogicalClass){
      ILogicExpression exp = new LogicExpression(
          (resource instanceof OWLUnionClass)?ILogicExpression.OR:ILogicExpression.AND);
      for(Object c: (Collection) ((OWLNAryLogicalClass) resource).getOperands() ){
        if(c instanceof RDFSClass){
          exp.add(convertParameter((RDFSClass)c));
        }else if(c instanceof RDFList){
          RDFList l = (RDFList) c;
          System.err.println("WARNING: unexpected list "+l.getBrowserText()+" in logic expression for "+getName());
        }
      }
View Full Code Here

      IRestriction t = ont.createRestriction(r.getRestrictionType());
      t.setProperty((IProperty)convertResource(ont,r.getProperty()));
      t.setParameter((ILogicExpression)convertResource(ont,r.getParameter()));
      return t;
    }else if(value instanceof ILogicExpression){
      ILogicExpression e = (ILogicExpression) value;
      ILogicExpression t = ont.createLogicExpression();
      t.setExpressionType(e.getExpressionType());
      for(Object o: e){
        t.add(convertResource(ont,o));
      }
      return t;
    }else if(value instanceof IProperty){
      return ont.getProperty(((IProperty) value).getName());
    }else if(value instanceof IClass){
View Full Code Here

      for(IClass c: source.getDisjointClasses()){
        cls.addDisjointClass((IClass)convertResource(ont,c));
      }
     
      // copy necessary restrictions
      ILogicExpression exp = source.getNecessaryRestrictions();
      if(exp.getExpressionType() == ILogicExpression.OR){
        cls.addSuperClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
      }else{
        for(Object c: exp){
          if(c instanceof IRestriction)
            cls.addNecessaryRestriction((IRestriction)convertResource(ont,c));
          else if(c instanceof IClass)
            cls.addSuperClass((IClass) convertResource(ont,c));
          else if(c instanceof ILogicExpression)
            cls.addSuperClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));   
        }
      }
     
      // copy equivalent restrictions
      exp = source.getEquivalentRestrictions();
      if(exp.getExpressionType() == ILogicExpression.OR){
        cls.addEquivalentClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
      }else{
        for(Object c: exp){
          if(c instanceof IRestriction)
            cls.addEquivalentRestriction((IRestriction)convertResource(ont,c));
View Full Code Here

        buffer.append("<tr valign=top><td><b>Equivalent Classes: </b></td><td>"+
            toHTML(cls.getEquivalentClasses())+"</td></tr>");
      if(cls.getDisjointClasses() != null && cls.getDisjointClasses().length > 0)
        buffer.append("<tr valign=top><td><b>Disjoint Classes: </b></td><td>"+
            toHTML(cls.getDisjointClasses())+"</td></tr>");
      ILogicExpression exp = cls.getEquivalentRestrictions();
      if(exp != null && !exp.isEmpty() )
        buffer.append("<tr valign=top><td><b>Equivalent Restrictions: </b></td><td>"+
            toHTML(exp)+"</td></tr>");
      exp = cls.getDirectNecessaryRestrictions();
      if(exp != null && !exp.isEmpty() )
        buffer.append("<tr valign=top><td><b>Necessary Restrictions: </b></td><td>"+
            toHTML(exp)+"</td></tr>");
      // do paths to root
      List<ClassPath> paths = getRootPaths(cls);
      if(!paths.isEmpty() ){
View Full Code Here

 
  /**
   * get equivalent restrictions for this class
   */
  public ILogicExpression getEquivalentRestrictions() {
    ILogicExpression exp = getOntology().createLogicExpression();
    exp.setExpressionType(ILogicExpression.AND);
   
    for(OWLEquivalentClassesAxiom ax: getDefiningOntology().getEquivalentClassesAxioms(getOWLClass())){
      for(OWLClassExpression ex: ax.getClassExpressions()){
        if(ex.isAnonymous()){
          exp.add(convertOWLObject(ex));
        }
      }
    }
    return (exp.size() == 1 && exp.get(0) instanceof ILogicExpression)?(ILogicExpression)exp.get(0):exp;
  }
View Full Code Here

    }
    return (exp.size() == 1 && exp.get(0) instanceof ILogicExpression)?(ILogicExpression)exp.get(0):exp;
  }

  public ILogicExpression getDirectNecessaryRestrictions() {
    ILogicExpression exp = getOntology().createLogicExpression();
    exp.setExpressionType(ILogicExpression.AND);
      for (OWLSubClassOfAxiom ax : getDefiningOntology().getSubClassAxiomsForSubClass(getOWLClass())) {
        OWLClassExpression ex = ax.getSuperClass();
      if(ex.isAnonymous()){
        exp.add(convertOWLObject(ex));
      }
     
    }
    return (exp.size() == 1 && exp.get(0) instanceof ILogicExpression)?(ILogicExpression)exp.get(0):exp;
  }
View Full Code Here

TOP

Related Classes of edu.pitt.ontology.ILogicExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.