Examples of IOntology


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

   * @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());
    }else{
      IResource r = target.getResource(src.getName());
      if(r instanceof IClass){
        dst = (IClass) r;
      }else{
        System.err.println("Error: expecting a class "+src.getName()+" but got a "+r);
      }
View Full Code Here

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

   * @param cls
   * @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())){
      dst.removeSuperClass(target.getRoot());
    }
     
    // copy superficial stuff
    for(String lbl: src.getLabels())
      dst.addLabel(lbl);
   
    for(String com: src.getComments())
      dst.addComment(com);
    if(src.getVersion() != null && dst.getVersion() != src.getVersion())
      dst.addVersion(src.getVersion());
 
    // copy properties values
    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 if not there
      dst.setPropertyValues(dp,src.getPropertyValues(sp));
View Full Code Here

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

public class FMAConcept extends Concept {
  public FMAConcept(IClass cls) {
    super(cls);
   
    // not lets do NCI Thesaurus specifics
    IOntology ont = cls.getOntology();
   
    // do codes
    IProperty code_p = ont.getProperty("FMAID");
    if(code_p != null){
      Object [] val = cls.getPropertyValues(code_p);
      if(val.length > 0){
        addCode(val[0].toString(),new Source("FMA"));
        setCode(val[0].toString());
      }
    }
    IProperty umls_p = ont.getProperty("UMLS_ID");
    if(umls_p != null){
      Object [] val = cls.getPropertyValues(umls_p);
      if(val.length > 0)
        addCode(val[0].toString(),new Source("UMLS"));
    }
   
    // do definitions
    List<Definition> deflist = new ArrayList<Definition>();
    IProperty def_p = ont.getProperty("definition");
    if(def_p != null){
      for(Object val : cls.getPropertyValues(def_p)){
        Definition d = new Definition(val.toString());
        deflist.add(d);
      }
View Full Code Here

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

public class BioPortalConcept extends Concept {
  public BioPortalConcept(IClass cls) {
    super(cls);
   
    // not lets do NCI Thesaurus specifics
    IOntology ont = cls.getOntology();
   
    // do code
    IProperty code_p = ont.getProperty(BioPortalHelper.CODE);
    if(code_p != null){
      for(Object val : cls.getPropertyValues(code_p)){
        addCode(val.toString(),new Source(val.toString()));
      }
    }
   
    // do sem type
    IProperty sem_p = ont.getProperty(BioPortalHelper.SEMANTIC_TYPE);
    if(sem_p != null){
      Object [] val = cls.getPropertyValues(sem_p);
      SemanticType [] types = new SemanticType [val.length];
      for(int i=0;i<val.length;i++){
        types[i] = SemanticType.getSemanticType(val[i].toString());
View Full Code Here

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

   * create a template object from SlideTutor ontology
   * @param url
   * @return
   */
  private void addSlideTutorTemplates(String url) throws Exception {
    IOntology ont = OOntology.loadOntology(url);
    ConceptRegistry.REGISTRY.put(url,SlideTutorConcept.class.getName());
   
    // create in-memory terminology from this ontology
    NobleCoderTerminology term = new NobleCoderTerminology();
    term.loadOntology(ont,null,true,true);
    term.setScoreConcepts(false);
    term.setSelectBestCandidate(false);
    term.setCachingEnabled(false);
   
    NobleCoderTerminology aterm = new NobleCoderTerminology();
    aterm.loadOntology(OOntology.loadOntology(""+ANATOMY_ONTOLOGY_URI),null,true,true);
    aterm.setCachingEnabled(false);
   
    // add a terminology to it
    CompositTerminology terminology = new CompositTerminology();
    terminology.addTerminology(term);
    terminology.addTerminology(aterm);
   
   
    // go over templates
    for(IClass template: ont.getClass("TEMPLATES").getDirectSubClasses()){
      // get orders
      final Map<String,Integer> conceptOrder = new HashMap<String,Integer>();
      for(Object o: template.getPropertyValues(ont.getProperty("order"))){
        String [] p = o.toString().split(":");
        if(p.length == 2){
          conceptOrder.put(p[0].trim(),new Integer(p[1].trim()));
        }
      }
      // get triggers
      //TODO:
     
      // get template contents
      List<IClass> templateContent = new ArrayList<IClass>();
      for(IRestriction r: template.getRestrictions(ont.getProperty("hasPrognostic"))){
        IClass c = (IClass) r.getParameter().getOperand();
        templateContent.add(c);
      }
     
      // sort them in order
View Full Code Here

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

   * create a template item from a given class
   * @param c
   * @return
   */
  private static TemplateItem convertSlideTutorClass(IClass c, Template template) {
    IOntology ont = c.getOntology();
    TemplateItem item = new TemplateItem();
    item.setTemplate(template);
    item.setConcept(c.getConcept());
    item.getConcept().setCode(getCode(item.getConcept().getCode(),true));
    item.setValueDomain(TemplateItem.DOMAIN_BOOLEAN);
   
    // figure out type
    if(isFeature(c)){
      item.setType(TemplateItem.TYPE_FINDING);
    }else if(isAttributeCategory(c)){
      item.setType(TemplateItem.TYPE_ATTRIBUTE);
    }else if(isLocation(c)){
      item.setType(TemplateItem.TYPE_ATTRIBUTE_VALUE);
    }else if(isNumber(c)){
      item.setType(TemplateItem.TYPE_NUMERIC_VALUE);
    }else if(isModifier(c)){
      item.setType(TemplateItem.TYPE_MODIFIER);
    }else if(isDisease(c)){
      item.setType(TemplateItem.TYPE_DIAGNOSIS);
      item.setValueDomain(TemplateItem.DOMAIN_SELF);
    }
   
    // if feature process attributes
    if(isFeature(c)){
      IClass feature = getFeature(c)
     
      if(!feature.equals(c)){
        item.setFeature(convertSlideTutorClass(feature,template));
       
        // if feature is a child of value then, it is a fully specified feature attr/value, and
        // we just need a feature
        if(isOfParent(c,VALUES))
          item = item.getFeature();
       
        // if we have a more general feature specified, then
       
      }
     
      // process potential attributes
      for(IClass attribute: getPotentialTemplateAttributes(c)){
        // if used attribute, skip
        //if(!usedAttributes.contains(attribute))
        //  continue;
       
        TemplateItem a = convertSlideTutorClass(attribute,template);
        // handle numbers
        if(isNumber(attribute)){
          item.getValues().add(a);
          item.setValueDomain(TemplateItem.DOMAIN_VALUE);
        // handle units
        }else if(isOfParent(attribute,"UNITS")){
          item.getUnits().add(a);
        // handle locations
        }else if(isLocation(attribute)){
          TemplateItem l = convertSlideTutorClass(ont.getClass(LOCATIONS), template);
          item.addAttributeValue(l,a);
        // handle attributes with categories and modifiers
        }else if(isModifier(attribute)){
          if(!attribute.hasSubClass(c))
            item.setValueDomain(TemplateItem.DOMAIN_ATTRIBUTE);
          for(IClass  acat : attribute.getDirectSuperClasses()){
            if(isAttributeCategory(acat) && !acat.equals(ont.getClass(MODIFIERS))){
              TemplateItem l = convertSlideTutorClass(acat, template);
              item.addAttributeValue(l, a);
            }else{
              item.addModifier(a);
            }
          }
        }else{
          //System.err.println(attribute);
        }
      }
     
      // do something special for worksheet?
      if(isWorksheet(c)){
        item.setValueDomain(TemplateItem.DOMAIN_SELF);
      }else if(isHeader(c)){
        item.setValueDomain(TemplateItem.DOMAIN_SELF);
      }
     
      // anatomic location? 
      if(isAnatomicLocation(c)){
        item.setType(TemplateItem.TYPE_ORGAN);
        String code = getCode((String) c.getPropertyValue(ont.getProperty("code")),true);
        if(code != null){
          String cd = (code.indexOf("#") > -1)?code.substring(0,code.lastIndexOf("#")):code;
          String nm = (cd.indexOf("/") > -1)?cd.substring(cd.lastIndexOf("/")+1):cd;
          Source src = new Source(nm, "", cd);
          try {
View Full Code Here

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

   * @return
   */
  public static boolean isOfParent(IClass cls,String parent){
    if(cls == null)
      return false;
    IOntology o = cls.getOntology();
    IClass p = o.getClass(parent);
    return cls.equals(p) || cls.hasSuperClass(p);
  }
View Full Code Here

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

   
    // assign code and name
    this.code = ""+cls.getURI();
    this.name = name;
   
    IOntology ontology = cls.getOntology();
    setDefinitions(getDefinitions(cls));
    setSources(new Source[] {new Source(ontology.getName(),ontology.getDescription(),""+ontology.getURI())});
    String [] labels = cls.getLabels();
    if(labels.length > 0){
      setName(labels[0]);
      setSynonyms(labels);
    }else{
View Full Code Here

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

        }
        for(int i=0;i<semTypeList.getModel().getSize();i++){
          semanticTypeFilter.add(SemanticType.getSemanticType(""+semTypeList.getModel().getElementAt(i)));
        }
        try {
          IOntology ont = OOntology.createOntology(URI.create(defaultURI+ontologyFile.getName()));
          export(term,rootFilter,semanticTypeFilter,ont);
          ont.write(new FileOutputStream(ontologyFile),IOntology.OWL_FORMAT);
        } catch (Exception e) {
          console.append("Error: "+e.getMessage()+"\n");
          JOptionPane.showMessageDialog(main,"Problems encounted during export","Error",JOptionPane.ERROR_MESSAGE);
          e.printStackTrace();
        }
View Full Code Here

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

  private void exportConcept(Concept c, List<SemanticType> semanticTypeFilter,String prefix, IClass parent) throws Exception {
    // first make sure that it fits the filter
    if(isFilteredOut(c, semanticTypeFilter)){
      return;
    }
    IOntology ont = parent.getOntology();
    String clsName = getClassName(c.getName());
    IClass cls = ont.getClass(clsName);
    // if class exists, then we have a cycle, just add a parent and quit
    if(cls != null){
      if(!(cls.equals(parent) || cls.hasSuperClass(parent) || cls.hasSubClass(parent)))
        cls.addSuperClass(parent);
      return;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.