Package edu.pitt.ontology

Examples of edu.pitt.ontology.IClass


  private void copyClass(BClass src, IOntology target){
    // if no such resource, then add it
    if(!target.hasResource(src.getName())){
      long time = System.currentTimeMillis();
     
      IClass dst = target.createClass(src.getName());
   
      // copy superficial stuff
      for(String lbl: src.getLabels())
        dst.addLabel(lbl);
      for(String com: src.getComments())
        dst.addComment(com);
      if(src.getVersion() != null)
        dst.addVersion(src.getVersion());
   
      // copy properties
      for(IProperty sp : src.getProperties()){
        // skip PartOf, and has_PART
        if(HAS_PART.equals(sp.getName()) || PART_OF.equals(sp.getName()))
          continue;
       
        IProperty dp = target.getProperty(sp.getName());
       
        // create unknown property for the first time
        if(dp == null && !target.hasResource(sp.getName())){
          dp = target.createProperty(sp.getName(),IProperty.ANNOTATION_DATATYPE);
          dp.setRange(new String [0]);
        }
       
        // copy string values
        dst.setPropertyValues(dp,src.getPropertyValues(sp));
       
      }
     
      // copy class information into special fields
      copyClassRelations(src,dst,SUPER_CLASS);
View Full Code Here


    if(e.getLabels().length > 0)
      buffer.append("<tr valign=top><td><b>Labels:</b></td><td>"+toHTML(e.getLabels())+"</td></tr>");
    if(e.getComments().length > 0)
      buffer.append("<tr valign=top><td><b>Comments: </b></td><td> "+toHTML(e.getComments())+"</td></tr>");
    if(e instanceof IClass){
      IClass cls = (IClass) e;
      if(cls.getDirectSuperClasses().length > 0)
        buffer.append("<tr valign=top><td><b>Super Classes: </b></td><td>"+
          toHTML(cls.getDirectSuperClasses())+"</td></tr>");
      if(cls.getEquivalentClasses() != null && cls.getEquivalentClasses().length > 0)
        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() ){
        buffer.append("<tr valign=top><td><b>Path(s) to Root: </b></td><td>");
        for(List<IClass> p: paths){
          buffer.append(toHTML(p)+"<br>");
        }
        buffer.append("</td></tr>");
      }
     
    }else if(e instanceof IProperty){
      IProperty cls = (IProperty) e;
      buffer.append("<tr valign=top><td><b>Domain: </b></td><td>"+
          toHTML(cls.getDomain())+"</td></tr>");
      buffer.append("<tr valign=top><td><b>Range: </b></td><td>"+
          toHTML(cls.getRange())+"</td></tr>");
    }else if(e instanceof IInstance){
      IInstance cls = (IInstance) e;
      buffer.append("<tr valign=top><td><b>Types: </b></td><td>"+
          toHTML(cls.getDirectTypes())+"</td></tr>");
    }
   
    IProperty[] p = e.getProperties();
    if(p.length > 0){
      buffer.append("<tr valign=top><td><b>Properties:</b>");
View Full Code Here

   * copy class content to target class
   * @param cls
   * @param target
   */
  private IClass getClass2(BClass src,IClass parent){
    IClass dst = null;
    IOntology target = parent.getOntology();
   
    // if no such resource, then add it
    if(!target.hasResource(src.getName())){
      dst = parent.createSubClass(src.getName());
View Full Code Here

   * @param target
   */
  private IClass copyClass2(BClass src,IClass parent){
    long time = System.currentTimeMillis();
    IOntology target = parent.getOntology();
    IClass dst = getClass2(src,parent);
   
    // if no such resource, then we are fucked
    if(dst == null)
      return null;
   
   
    // add superclasses if needed (avoid infinite loops)
    for(IClass cls : src.getDirectSuperClasses()){
      if(cls.getName().equals(parent.getName()) || cls.equals(src))
        continue;
      // add superclass
      IClass p = getClass2((BClass)cls,target.getRoot());
      if(p != null && !p.hasSuperClass(p))
        dst.addSuperClass(p);
    }
   
    // remove root class as parent if it is not in source, but in destination
    if(src.getDirectSuperClasses().length > 0 && dst.hasDirectSuperClass(target.getRoot()) && !src.hasDirectSuperClass(src.getOntology().getRoot())){
View Full Code Here

    return new String[] { "en" };
  }

  public Concept[] getRelatedConcepts(Concept c, Relation r)
      throws TerminologyException {
    IClass cls = c.getConceptClass();
    if (r == Relation.BROADER) {
      // IClass cls = ontology.getClass(c.getCode());
      if (cls != null) {
        return convertConcepts(cls.getDirectSuperClasses());
      }
    } else if (r == Relation.NARROWER) {
      // IClass cls = ontology.getClass(c.getCode());
      if (cls != null) {
        return convertConcepts(cls.getDirectSubClasses());
      }
    } else if (r == Relation.SIMILAR) {
      // IClass cls = ontology.getClass(c.getCode());
      if (cls != null) {
        List<IClass> clses = new ArrayList<IClass>();
        for (IClass eq : cls.getEquivalentClasses()) {
          if (!eq.isAnonymous()) {
            clses.add(eq);
          }
        }
        return convertConcepts(clses);
View Full Code Here

          Element n = getElementByTagName(e,"conceptIdShort");
          if(n != null){
            String name = n.getTextContent().trim();
            //IClass cls = getClass(name);
            //if(cls == null)
            IClass cls = new BClass(this,name);
            cls.getConcept().setSearchString(text);
            cls.getConcept().setTerminology(this);
            list.add(cls.getConcept());
          }
        }
      }
      return list.toArray(new Concept [0]);
    }
View Full Code Here

      if(entry instanceof Concept){
        try{
          return ((Concept)entry).getChildrenConcepts().length > 0;
        }catch(TerminologyException ex){}
      }else if(entry instanceof IClass){
        IClass cls = (IClass) entry;
        return cls.getDirectSubClasses().length > 0 || cls.getDirectInstances().length > 0;
      }
      return false;
    }
View Full Code Here

    throw new IOntologyError("Operation Not Supported");
  }

  public boolean evaluate(Object obj) {
    if(obj instanceof IClass){
      IClass c2 = (IClass) obj;
      return equals(c2) || hasSubClass(c2);
    }else if(obj instanceof IInstance){
      IInstance i2 = (IInstance) obj;
      return i2.hasType(this);
    }
View Full Code Here

    load();
   
    // load list of classes
    Set<IClass> list = new LinkedHashSet<IClass>();
    for(String s: getList(key)){
      IClass c = ontology.getClass(s);
      if(c != null)
        list.add(c);
    }
    return list;
  }
View Full Code Here

TOP

Related Classes of edu.pitt.ontology.IClass

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.