Package edu.pitt.terminology.lexicon

Examples of edu.pitt.terminology.lexicon.Concept$TextLengthComparator


    //String server = "http://lexevsapi51.nci.nih.gov/lexevsapi51#NCI MetaThesaurus";
    Terminology term = new LexEVSRestTerminology(server);
    long time = System.currentTimeMillis();
    // ZFA_0001234 | C0025202
    System.out.println("--- lookup ---");
    Concept c = term.lookupConcept("C0025202");
    if(c != null){
      c.printInfo(System.out);
    }
    System.out.println("lookup time "+(System.currentTimeMillis()-time));
   
    System.out.println("--- search ---");
   
View Full Code Here


        ResultSet result =  st.executeQuery("SELECT DISTINCT cui, str FROM mrconso WHERE "+condition+filter);
        while(result.next()){
          String cui  = result.getString("cui");
          String str = result.getString("str");
         
          Concept c = new Concept(cui,str);
          c.setTerminology(this);
          c.setSearchString(text);
         
          if(!conceptList.contains(c))
            conceptList.add(c);
        }
        result.close();
View Full Code Here

  public static void main(String[] args) throws Exception {
    Terminology term = new UMLSTerminology("oracle.jdbc.driver.OracleDriver",
        "jdbc:oracle:thin:@lnx01.dbmi.pitt.edu:1521:dbmi01", "umls","dbmi09umls");
   
    // lookup concept
    Concept melanoma = term.lookupConcept("C0025202");
    melanoma.printInfo(System.out);
    term.setFilterSources(term.getSources("NCI"));
    System.out.println("--");
    // do search
    long time = System.currentTimeMillis();
    for(String text: new String [] {"blue tumor"}){
View Full Code Here

    BioPortalTerminology term = new BioPortalTerminology();
    term.setOntology("NCI_Thesaurus");
    long time = System.currentTimeMillis();
    // ZFA_0001234 | C0025202
    System.out.println("--- lookup ---");
    Concept c = term.lookupConcept("C0025202");
    if(c != null){
      c.printInfo(System.out);
    }
   
    System.out.println("lookup time "+(System.currentTimeMillis()-time));
   
    System.out.println("--- search ---");
View Full Code Here

        if("org.LexGrid.concepts.Concept".equals(name)){
          Map<String,Object> content = processElement(element);
         
          // setup some usefull values
          String cui   = ""+content.get("_entityCode");
          Concept concept = new Concept(cui);
          String preferredName = null;
         
          // set synonyms and terms
          List<Term> terms = new ArrayList<Term>();
          List<String> synonyms = new ArrayList<String>();
          Set<Source> sources = new HashSet<Source>();
          if(content.containsKey("_presentationList")){
            for(Map m: (List<Map>) content.get("_presentationList")){
              if("org.LexGrid.concepts.Presentation".equals(m.get("name"))){
                String pt = ""+m.get("_isPreferred");
                String text = null;
                String lang = (String) m.get("_language");
                String form = (String) m.get("_representationalForm");
                Source src = null;
               
                // get content
                Map tm = ((List<Map>) m.get("_value")).get(0);
                if("org.LexGrid.commonTypes.Text".equals(tm.get("name"))){
                  text = ""+tm.get("_content");
                  synonyms.add(text.trim());
                }
               
                // get source
                List<Map> sl = (List<Map>) m.get("_sourceList");
                if(sl != null && !sl.isEmpty()){
                  Map sm = sl.get(0);
                  if("org.LexGrid.commonTypes.Source".equals(sm.get("name"))){
                    String s = (String) sm.get("_content");
                    if(s != null){
                      src = new Source(s);
                      sources.add(src);
                    }
                  }
                }
               
                if(text != null){
                  Term term = new Term(text);
                  term.setPreferred(Boolean.parseBoolean(pt));
                  term.setLanguage(lang);
                  term.setForm(form);
                  if(src != null)
                    term.setSource(src);
                  terms.add(term);
                }
              }
            }
          }
         
          // set definitions and terms
          List<Definition> defs = new ArrayList<Definition>();
          if(content.containsKey("_definitionList")){
            for(Map m: (List<Map>) content.get("_definitionList")){
              if("org.LexGrid.concepts.Definition".equals(m.get("name"))){
                String text = null;
                Source src = null;
               
                Map tm = ((List<Map>) m.get("_value")).get(0);
                if("org.LexGrid.commonTypes.Text".equals(tm.get("name"))){
                  text = ""+tm.get("_content");
                }
                // get source
                List<Map> sl = (List<Map>) m.get("_sourceList");
                if(sl != null && !sl.isEmpty()){
                  Map sm = sl.get(0);
                  if("org.LexGrid.commonTypes.Source".equals(sm.get("name"))){
                    String s = (String) sm.get("_content");
                    if(s != null){
                      src = new Source(s);
                    }
                  }
                }
               
                if(text != null){
                  Definition d = new Definition(text);
                  if(src != null)
                    d.setSource(src);
                  defs.add(d);
                }
              }
            }
          }
         
          // set preferred name
          if(content.containsKey("_entityDescription")){
            for(Map m: (List<Map>) content.get("_entityDescription")){
              if("org.LexGrid.commonTypes.EntityDescription" .equals(m.get("name"))){
                preferredName = ""+m.get("_content");
              }
            }
          }
         
          // get properties
          // set definitions and terms
          Properties props = new Properties();
          if(content.containsKey("_propertyList")){
            for(Map m: (List<Map>) content.get("_propertyList")){
              if("org.LexGrid.commonTypes.Property".equals(m.get("name"))){
                String value = null;
                String prop = (String) m.get("_propertyName");
               
                Map tm = ((List<Map>) m.get("_value")).get(0);
                if("org.LexGrid.commonTypes.Text".equals(tm.get("name"))){
                  value =  (String) tm.get("_content");
                }
             
                if(prop != null && value != null){
                  props.setProperty(prop, value);
                }
              }
            }
          }
           
         
          // set name
          concept.setName(preferredName);
          concept.setTerminology(this);
          concept.setSynonyms(synonyms.toArray(new String [0]));
          concept.setTerms(terms.toArray(new Term [0]));
          concept.setDefinitions(defs.toArray(new Definition[0]));
          concept.setSources(sources.toArray(new Source [0]));
          concept.setProperties(props);
          if(props.containsKey("Semantic_Type")){
            concept.setSemanticTypes(new SemanticType []{new SemanticType(props.getProperty("Semantic_Type"))});
          }
         
          concept.setInitialized(true);
         
          return concept;
        }
      }
     
View Full Code Here

      IOntology ont = onts[0];
      System.out.println(ont.getRoot()+" : "+Arrays.toString(ont.getRootClasses()));
      IClass [] clses = new IClass [] { ont.getClass("Melanoma") };
      for(IClass cls :clses){
        System.out.println(cls+" "+cls.getLocation());
        Concept c = cls.getConcept();
        c.printInfo(System.out);
      }
    }
  }
View Full Code Here

          ex.printStackTrace();
          //NOOP, just do default
        }
      }
    }
    return new Concept(cls);
  }
View Full Code Here

    return pathHelper;
  }
 
  protected void doViewRelationships(String code) {
    try {
      Concept c = terminology.lookupConcept(code);
      if(c != null){
        StringBuffer str = new StringBuffer();
        // narrower concepts
        str.append("<h3>Direct Children of <font color=green>"+c.getName()+" ("+c.getCode()+")</font></h3>");
        str.append("<ul>");
        for(Concept a: c.getChildrenConcepts()){
          String h = "<a href=\""+a.getCode()+"\">"+a.getCode()+"</a>";
          str.append("<li><b>"+a.getName()+"</b> ("+h+") "+Arrays.toString(a.getSemanticTypes())+"</li>");
        }
        str.append("</ul>");
        str.append("<h3>Direct Parents of <font color=green>"+c.getName()+" ("+c.getCode()+")</font></h3>");
        for(Concept a: c.getParentConcepts()){
          String h = "<a href=\""+a.getCode()+"\">"+a.getCode()+"</a>";
          str.append("<li><b>"+a.getName()+"</b> ("+h+") "+Arrays.toString(a.getSemanticTypes())+"</li>");
        }
        str.append("</ul>");
        // ancestry
        str.append("<h3>All Ancestors of <font color=green>"+c.getName()+" ("+c.getCode()+") </font></h3>");
        Map<Concept,Integer> ancestors = getPathHelper().getAncestors(c);
        if(ancestors != null && !ancestors.isEmpty()){
          for(Concept a: ancestors.keySet()){
            try {
              a.initialize();
View Full Code Here

    }
  }
 
  private Concept[] doLookup(String text) throws Exception{
    if(isCode(text)){
      Concept c = terminology.lookupConcept(text);
      return c != null? new Concept []{c}:new Concept [0];
    }
    return terminology.search(text);
  }
View Full Code Here

  public Concept getConcept() {
    //return  new Concept(getId(),getName());
    if(concept == null){
      load();
      concept = new Concept(this);
     
      // add codes
      if(properties.containsKey(CODE)){
        Object val = properties.get(CODE);
        int i = 0;
View Full Code Here

TOP

Related Classes of edu.pitt.terminology.lexicon.Concept$TextLengthComparator

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.