Package edu.pitt.terminology.lexicon

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


  private List<ConceptPath> toPaths(Terminology t, List<List<String>> paths) {
    List<ConceptPath> n = new ArrayList<ConceptPath>();
    for(List<String> p: paths){
      ConceptPath np = new ConceptPath();
      for(String s: p){
        Concept c = new Concept(s);
        c.setTerminology(t);
        np.add(c);
      }
      n.add(np);
    }
    return n;
View Full Code Here


    //return getAncestors(getPaths(c));
    Map<Concept,Integer> result = new LinkedHashMap<Concept, Integer>();
    try {
      Map<String, Integer> map = getAncestors(c,new HashSet<Concept>());
      for(String nm: map.keySet()){
        Concept cn = new Concept(nm);
        cn.setTerminology(terminology);
        result.put(cn,map.get(nm));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

      for(Concept c: negex.getNegations())
        Collections.addAll(annotations,c.getAnnotations());
    }
   
    // parse concept for its attributes and values
    Concept c = findConcept(templateItem.getFeature());
    if(c != null){
      setFeature(new ItemInstance(templateItem.getFeature(),c));
    }

    // set attributes and modifiers
View Full Code Here

        offsets.put(en,en+WINDOW);
     
      for(int off: offsets.keySet()){
        for(int i=off;i>=0 && i<offsets.get(off) && i< doc.getAnnotations().size();i++){
          Annotation a = doc.getAnnotations().get(i);
          Concept c = a.getConcept();
          if(r.contains(c)){
            for(Concept b: r){
              if(!Arrays.asList(b.getAnnotations()).contains(a)){
                r.add(c);
                break;
View Full Code Here

        return super.add(e);
      }
     
    };
    for(TemplateItem mod: items){
      Concept c = (r == null)?findConcept(mod):findConcept(r,mod);
      if(c != null){
        result.add(new ItemInstance(mod, c));
      }
    }
    return result;
View Full Code Here

   * @param out -
   * @param s
   * @return
   */
  private Concept findConcept(TemplateItem in){
    Concept c = in.getConcept();
    try{
      IndexFinderTerminology term = new IndexFinderTerminology();
      term.setIgnoreSmallWords(false);
      term.setScoreConcepts(false);
      term.setSelectBestCandidate(false);
      term.setIgnoreUsedWords(true);
      term.setCachingEnabled(false);
      term.addConcept(c);
     
      for(Concept rc: term.search(getConcept().getSearchString())){
        rc.setTerminology(c.getTerminology());
        return rc;
      }
    }catch(TerminologyException ex){
      //ex.printStackTrace();
     
View Full Code Here

        response = processOutput(c);
      }else if ( action.equals("get_roots")){
        response = processOutput(terminology.getRootConcepts());
      }else if ( action.equals("lookup_concept")){
        String text = req.getParameter("code");
        Concept c = terminology.lookupConcept(text.trim());
        response = processOutput(c);
      }else if ( action.equals("get_sources")){
        Source [] src = terminology.getSources();
        response = processOutput(src);
      }else if ( action.equals("get_related_concepts")){
        String code = req.getParameter("code");
        String rel  = req.getParameter("relation");
        Concept c = terminology.lookupConcept(code.trim());
       
        /*
        try{
          code = URLDecoder.decode(code,"utf-8");
        }catch(Exception ex){}
        */
       
        // find relationship
        if(c != null){
          Relation r = Relation.BROADER; // default
          rel = rel.toLowerCase();
          Relation [] rs = c.getRelations();
          for(int i=0;i<rs.length;i++){
            if(rs[i].getName().toLowerCase().contains(rel) ||
               rs[i].getCode().toLowerCase().contains(rel)){
              r = rs[i];
              break;
            }
          }
          Concept [] cs = terminology.getRelatedConcepts(c, r);
          response = processOutput(cs);
        }else{
          response = processOutput(new Concept [0]);
        }
      }else if ( action.equals("get_related_concept_map")){
        String code = req.getParameter("code");
        Concept c = terminology.lookupConcept(code);
        // find relationship
        Map cs = terminology.getRelatedConcepts(c);
        response = processOutput(cs);
      }
    }catch(TerminologyException ex){
View Full Code Here

    //if(obj == null)
    //  System.err.println("object is null");
    StringBuffer buff = new StringBuffer();
    if(obj instanceof Concept){
      String clr = " bgcolor=\"#EEEEEE\"";
      Concept c = (Concept) obj;
      buff.append("<table border=0>");
      buff.append("<tr valign=top><td"+clr+">code</td><td>"+c.getCode()+"</td></tr>");
      buff.append("<tr valign=top><td"+clr+">name</td><td>"+c.getName()+"</td></tr>");
      SemanticType [] sem = c.getSemanticTypes();
      StringBuffer sembuff = new StringBuffer();
      if(sem != null && sem.length >0){
        for(int j=0;j<sem.length;j++)
          sembuff.append(sem[j].getName()+" ");
      }
      buff.append("<tr valign=top><td"+clr+">semantic types</td><td>"+sembuff+"</td></tr>");
      buff.append("<tr valign=top><td"+clr+">definitions</td><td><ul>");
      Definition [] def = c.getDefinitions();
      if(def != null)
        for(int j=0;j<def.length;j++)
          buff.append("<li>"+def[j].getDefinition()+" ["+def[j].getSource()+"]</li>");
      buff.append("</ul></td></tr>");
      buff.append("<tr valign=top><td"+clr+">synonyms</td><td>");
      String [] syn = c.getSynonyms();
      if(syn != null)
        for(int j=0;j<syn.length;j++)
          buff.append(syn[j]+", ");
      buff.append("</td></tr>");
      buff.append("<tr valign=top><td"+clr+">sources</td><td>");
      Source [] src = c.getSources();
      if(src != null)
        for(int j=0;j<src.length;j++)
          buff.append(src[j]+", ");
      buff.append("</td></tr>");
      buff.append("<tr valign=top><td"+clr+">relations</td><td>");
      Relation [] rs = c.getRelations();
      if(rs != null)
        for(int j=0;j<rs.length;j++){
          String code = c.getCode();
          try{
            code = URLEncoder.encode(c.getCode(),"utf-8");
          }catch(Exception ex){}
          String url = servletName+"?action=get_related_concepts&relation="+rs[j].getName()+"&code="+code;
          buff.append("<a href=\""+url+"\">"+rs[j].getName()+"</a>, ");
        }
      buff.append("</td></tr>");
      buff.append("<tr valign=top><td"+clr+">codes</td><td>");
      Map mp = c.getCodes();
      if(mp != null)
        for(Object o: mp.keySet())
          buff.append(o+" = "+mp.get(o)+", ");
      buff.append("</td></tr>");
      buff.append("</table>");
View Full Code Here

        tosend = terminology.lookupConcept((String) parcel.getPayload());
      }else if ( action.equals("get_sources")){
        tosend = terminology.getSources();
      }else if ( action.equals("get_related_concepts")){
        Object [] p = (Object []) parcel.getPayload();
        Concept c = (Concept) p[0];
        Relation r = (Relation) p[1];
        tosend = terminology.getRelatedConcepts(c, r);
      }else if ( action.equals("get_related_concept_map")){
        Concept c = (Concept) parcel.getPayload();
        tosend = terminology.getRelatedConcepts(c);
      }else if ( action.equals("get_terminologies")){
        tosend = terminologyParams.keySet();
      }
    }catch(TerminologyException ex){
View Full Code Here

        addInstance(paths, items, item);
      }else if(concept.getCodes() != null && !concept.getCodes().isEmpty() && c.getSources().length > 0){
        // what if there is a linkage code
        String code = concept.getCode(c.getSources()[0]);
        if(code != null){
          Concept cc = (code.equals(c.getSources()[0].getName()))?c.getTerminology().getRootConcepts()[0]:c.getTerminology().lookupConcept(code);
          if(cc != null){
            if(paths.hasAncestor(c,cc)){
              ItemInstance item = new ItemInstance(this,c);
              item.process(doc);
              addInstance(paths, items, item);
View Full Code Here

TOP

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

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.