Package edu.pitt.dbmi.nlp.noble.ontology

Examples of edu.pitt.dbmi.nlp.noble.ontology.IClass


    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

    // if we got a uri as a code
    int i = name.lastIndexOf("#");
    if(i > -1)
      name = name.substring(i+1);
    // fetch class
    IClass cls = classMap.get(name);
   
    // try some derivative of a name
    if(cls == null){
      cls = classMap.get(deriveName(name));
    }
View Full Code Here

  public IRepository getRepository() {
    return repository;
  }

  public IResource getResource(String name) {
    IClass c = getClass(name);
    // search if not in caseh, can't rely on lookup
    // cause class name and location are not always the same things
    if(c == null){
      try{
        Concept [] result = search(BioPortalHelper.getName(name));
View Full Code Here

    partOf.setInverseProperty(hasPart);
   
    // now that we have all classes, build a tree, since classes only have the superclasses set
    IResourceIterator it = target.getAllClasses();
    while(it.hasNext()){
      IClass cls = (IClass) it.next();
     
      long time = System.currentTimeMillis();
     
      // now copy equivalent classes classes
      IProperty p = target.getProperty(EQUIVALENT_CLASS);
      if(p != null){
        for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
          cls.addEquivalentClass(sibling);
        }
        // remove temporary property
        cls.removePropertyValues(p);
      }
     
      // setup direct subclasses and superclasses
      p = target.getProperty(SUPER_CLASS);
      if(p != null){
        for(IClass parent: getClassList(target,cls.getPropertyValues(p))){
          if(!cls.hasDirectSuperClass(parent)){ 
            // add string as a true superclass
            cls.addSuperClass(parent);
            // if superclass is not root, then add this class
            // as a child and remove root as parent
            if(!parent.equals(target.getRoot())){
              parent.addSubClass(cls);
             
              // since everything was added as root, cleanup
              cls.removeSuperClass(target.getRoot());
            }
          }     
        }
       
        // remove temporary property
        cls.removePropertyValues(p);
      }
     
      // setup direct subclasses and superclasses
      p = target.getProperty(SUB_CLASS);
      if(p != null){
        for(IClass child: getClassList(target,cls.getPropertyValues(p))){
          if(!cls.hasDirectSubClass(child)){
            // add string as a true superclass
            cls.addSubClass(child);
            child.addSuperClass(cls);
           
            // if superclass is not root, then add this class
            // as a child and remove root as parent
            if(child.hasDirectSuperClass(target.getRoot())){
              // since everything was added as root, cleanup
              child.removeSuperClass(target.getRoot());
            }
          }
        }
       
        // remove temporary property
        cls.removePropertyValues(p);
      }
     
     
      // now copy disjoint classes
      p = target.getProperty(DISJOINT_CLASS);
      if(p != null){
        for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
          cls.addDisjointClass(sibling);
        }
        // remove temporary property
        cls.removePropertyValues(p);
      }
   
      // now copy other relationships relationships
      for(String relation: new String [] {PART_OF, HAS_PART}){
        p = target.getProperty("annotation_"+relation);
        if(p != null){
          for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
           
            IRestriction r = target.createRestriction(IRestriction.SOME_VALUES_FROM);
            r.setProperty(target.getProperty(relation));
            r.setParameter(sibling.getLogicExpression());
            cls.addNecessaryRestriction(r);
          }
          // remove temporary property
          cls.removePropertyValues(p);
        }
      }
     
     
     
View Full Code Here

    List<IClass> list = new ArrayList<IClass>();
    for(Object s: obj){
      String name = (String) s;
      // check for valid names
      if(name.matches("[\\w-]+")){
        IClass cls = ont.getClass(name);
        if(cls != null)
          list.add(cls);
      }
    }
    return list;
View Full Code Here

  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

   * 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

TOP

Related Classes of edu.pitt.dbmi.nlp.noble.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.