Package edu.pitt.dbmi.nlp.noble.terminology.impl

Examples of edu.pitt.dbmi.nlp.noble.terminology.impl.NobleCoderTerminology


    // check if already loaded
    if("done".equals(storage.getInfoMap().get("status")))
      return;
   
    // handle memory nightmare (save when you reach 90%)
    final NobleCoderTerminology t = terminology;
    MemoryManager.setMemoryThreshold(new Runnable(){
      public void run() {
        t.crash();
      }
    },0.95);
   
    // try to extract the name from the directory
    int i=0,offset = 0;
View Full Code Here


   * @return
   */
  private Concept findConcept(TemplateItem in){
    Concept c = in.getConcept();
    try{
      NobleCoderTerminology term = new NobleCoderTerminology();
      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

    boolean createAncestry = params.contains("-createAncestry");
    boolean abbreviateURI = params.contains("-abbreviateURIcodes");
   
   
    // start index finder terminology
    NobleCoderTerminology terminology = new NobleCoderTerminology();
    terminology.addPropertyChangeListener(this);
    terminology.setStemWords(stemWords);
    terminology.setIgnoreDigits(stripDigits);
   
    // setup persistance directory
    String name = null;
    if(output != null){
      File f = new File(output);
      if(f.getParentFile().exists()){
        if(f.isDirectory()){
          NobleCoderTerminology.setPersistenceDirectory(f);
        }else{
          NobleCoderTerminology.setPersistenceDirectory(f.getParentFile());
          name = f.getName();
        }
      }
    }
   
    // load approprate ontology   
    if(rrf != null){
      File f = new File(rrf);
      List<String> lang = (lng != null)?readList(lng):null;
      List<String> src =  (sr  != null)?readList(sr):null;
      List<String> hsrc =  (hsr  != null)?readList(hsr):null;
      List<String> sem =  (se  != null)?readList(se):null;
     
      // load ontology
      log("Loading RRF terminology from "+f.getAbsolutePath()+"...");
      log("Languages: "+lang);
      log("Sources: "+src);
      log("Hierarchy Sources: "+hsrc);
      log("SemanticTypes: "+sem);
     
      Map<String,List<String>> pmap = new HashMap<String,List<String>>();
      pmap.put("name",Arrays.asList(name));
      pmap.put("languages",lang);
      pmap.put("sources",src);
      pmap.put("semanticTypes",sem);
      pmap.put("hierarchySources",hsrc);
      terminology.loadRRF(f,pmap);
      name = (name == null)?f.getName():name;
    }else if(owl != null){
      log("Loading OWL terminology from "+owl+"...");
      IOntology ont = OOntology.loadOntology(owl);
      if(ont != null){
        terminology.loadOntology(ont,name,false,abbreviateURI);
      }
      name = (name == null)?ont.getName():name;
    }else if(obo != null){
      log("Loading OBO terminology from "+obo+"...");
      if(name == null){
        name = (new File(obo)).getName();
        if(name.endsWith(".obo"))
          name = name.substring(0,name.length()-4);
      }
      terminology.load(name);
      ConceptImporter.getInstance().addPropertyChangeListener(this);
      ConceptImporter.getInstance().loadOBO(terminology,new File(obo));
      ConceptImporter.getInstance().removePropertyChangeListener(this);
      terminology.save();
    }else if(bioportal != null){
      log("Loading BioPortal terminology from "+bioportal+"...");
      BioPortalRepository r = new BioPortalRepository();
      IOntology ont = r.getOntology(URI.create(bioportal));
      if(ont != null){
        ont.addPropertyChangeListener(this);
        terminology.loadOntology(ont,name);
      }
      name = (name == null)?ont.getName():name;
    }else if(txt != null){
      log("Loading Text terminology from "+txt+"...");
      File f = new File(txt);
      terminology.loadText(f,name);
      name = (name == null)?f.getName():name;
    }
   
    //print info
    log("Testing Terminology "+name+" ...");
View Full Code Here

     }
 
  private void loadDefaults(){
    // set up defaults
    terminology = null;
    NobleCoderTerminology t = getTerminology();
    if(t != null){
      // set semantic types
      String s = "";
      for(SemanticType st: t.getFilterSemanticType()){
        s+=st.getName()+";";
      }
      if(s.length() > 0){
        filterBySemanticTypes.setSelected(true);
        semanticTypes.setEditable(true);
        semanticTypes.setText(s.substring(0,s.length()-1));
        b1.setEnabled(true);
      }else{
        filterBySemanticTypes.setSelected(false);
        semanticTypes.setText("");
      }
      // set sources
      s = "";
      for(Source st: t.getFilterSources()){
        s+=st.getName()+";";
      }
      if(s.length() > 0){
        filterBySources.setSelected(true);
        sources.setEditable(true);
        sources.setText(s.substring(0,s.length()-1));
        b2.setEnabled(true);
      }else{
        filterBySources.setSelected(false);
        sources.setText("");
      }
     
      searchMethods.setSelectedItem(t.getDefaultSearchMethod());
      stripSmallWords.setSelected(t.isIgnoreSmallWords());
      stripCommonWords.setSelected(t.isIgnoreCommonWords());
      stripDigits.setSelected(t.isIgnoreDigits());
      selectBestCandidates.setSelected(t.isSelectBestCandidate());
      useSlidingWindow.setSelected(t.getWindowSize() > 0);
      slidingWindow.setText(""+t.getWindowSize());
      handleAbbreviations.setSelected(t.isIgnoreAcronyms());
      ignoreUsedWords.setSelected(t.isIgnoreUsedWords());
      subsumptionMode.setSelected(t.isSubsumptionMode());
      overlapMode.setSelected(t.isOverlapMode());
      contiguousMode.setSelected(t.isContiguousMode());
      orderedMode.setSelected(t.isOrderedMode());
      partialMode.setSelected(t.isPartialMode());
      handleAcronymExpansion.setSelected(isAcronymExpansion());
      handleNegationDetection.setSelected(isHandleNegation());
      semanticPanel = null;
      sourcePanel = null;
     
View Full Code Here

   * all of the relevant settings should be set in .term/search.properties
   * @param location
   */
  public NobleCoder(File location) throws IOException {
    NobleCoderTerminology.setPersistenceDirectory(location.getParentFile());
    setTerminology(new NobleCoderTerminology(location.getName()));
  }
View Full Code Here

   * invoke NobleCoderTool pointing to a terminology .term direcotry
   * all of the relevant settings should be set in .term/search.properties
   * @param location
   */
  public NobleCoder(String name) throws IOException {
    setTerminology(new NobleCoderTerminology(name));
  }
View Full Code Here

      if (!nobleDirectory.exists() || !nobleDirectory.isDirectory()) {
        throw (new Exception("Cannot find directory for  "
            + nobleDirectory.getAbsolutePath()));
      }

      coder = new NobleCoderTerminology(nobleDirectory.getAbsolutePath());
      initializeParameters();

      if (debugging) {
        System.out
            .println("Successfully opened NobleCoder data source.");
View Full Code Here

TOP

Related Classes of edu.pitt.dbmi.nlp.noble.terminology.impl.NobleCoderTerminology

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.