Package edu.pitt.terminology.client

Examples of edu.pitt.terminology.client.IndexFinderTerminology


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

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

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


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

   * invoke NobleCoder 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 {
    terminology = new IndexFinderTerminology(name);
    setupAcronyms(new File(IndexFinderTerminology.getPersistenceDirectory(),
    name.endsWith(IndexFinderTerminology.TERM_SUFFIX)?name:name+IndexFinderTerminology.TERM_SUFFIX));
  }
View Full Code Here

          if(abbreviationWhitelistText != null){
            abbreviationWhitelistText.setText(af.getAbsolutePath());
          }
        }
        abbreviationWhitelist = loadResource(af.getAbsolutePath());
        abbreviations = (IndexFinderTerminology) new IndexFinderTerminology(
            new File(location,p.getProperty("abbreviation.terminology",ABBREV_TERMINOLOGY)).getAbsolutePath());
        skipAbbrreviationLogic = false;
      }
    }
  }
View Full Code Here

     }
 
  private void loadDefaults(){
    // set up defaults
    terminology = null;
    IndexFinderTerminology 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;
     
      try {
        setupAcronyms(new File(t.getLocation()));
      } catch (IOException e) {
        e.printStackTrace();
      }
     
      syncOptions();
View Full Code Here

    }
   
    //load terminology
    List<Terminology> terms = new ArrayList<Terminology>();
    for(Element t: XMLUtils.getElementsByTagName(element,"Terminology")){
      IndexFinderTerminology term = new IndexFinderTerminology();
      term.fromElement(t);
      terms.add(term);
    }
    //term.setCachingEnabled(false);
    if(terms.size() == 1){
      setTerminology(terms.get(0));
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception {
    IndexFinderTerminology.setPersistenceDirectory(new File("/home/tseytlin/Data/Terminologies/IndexFinder"));
    Terminology terminology = new IndexFinderTerminology("TIES_Pathology");
    //Terminology terminology = new IndexFinderTerminology("NCI_Thesaurus");
    PathHelper ph = new PathHelper(terminology);
    //ph.createAncestryCache();
    for(String text: Arrays.asList("melanoma","nevus","skin","margin")){
      for(Concept c: terminology.search(text)){
        long t = System.currentTimeMillis();
        // lookup paths
       
        List<ConceptPath> path = ph.getPaths(c);
        t = System.currentTimeMillis()-t;
View Full Code Here

   * @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

    boolean stemWords = params.contains("-stemWords");
    boolean stripDigits = params.contains("-stripDigits");
    boolean createAncestry = params.contains("-createAncestry");
   
    // start index finder terminology
    IndexFinderTerminology terminology = new IndexFinderTerminology();
    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()){
          IndexFinderTerminology.setPersistenceDirectory(f);
        }else{
          IndexFinderTerminology.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 = POntology.loadOntology(owl);
      if(ont != null){
        terminology.loadOntology(ont,name);
      }
      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

  /**
   * create a template from terminology where each root is a template item
   * @param url
   */
  private void addTerminologyTemplate(String url) throws Exception {
    Terminology terminology = new IndexFinderTerminology(url);
   
    // setup template
    Template template = new Template();
    template.setName(terminology.getName()+" Template");
    template.setDescription(terminology.getDescription());
    template.setTerminology(terminology);
    template.getFilters().add(new DocumentFilter("(?s)^BACKGROUND:$.*^$",true));
   
    for(Concept c: terminology.getRootConcepts()){
      TemplateItem item = new TemplateItem();
      /*     
      {
        //TODO: this is a hack for BRAF, let it stay for now?
        public List<ItemInstance> process(AnnotatedDocument doc) throws TerminologyException {
View Full Code Here

TOP

Related Classes of edu.pitt.terminology.client.IndexFinderTerminology

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.